当前位置: 首页>>代码示例>>Java>>正文


Java IEnergizedItem类代码示例

本文整理汇总了Java中mekanism.api.energy.IEnergizedItem的典型用法代码示例。如果您正苦于以下问题:Java IEnergizedItem类的具体用法?Java IEnergizedItem怎么用?Java IEnergizedItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IEnergizedItem类属于mekanism.api.energy包,在下文中一共展示了IEnergizedItem类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: chargeItemStack

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
public void chargeItemStack(ItemStack itemstack)
{
	if(itemstack != null)
	{
		if(itemstack.getItem() instanceof IEnergizedItem)
		{
			setEnergy(getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy()));
		}
		else if(MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem)
		{
			double sent = ElectricItem.manager.charge(itemstack, (int)(getEnergy()*general.TO_IC2), 4, true, false)*general.FROM_IC2;
			setEnergy(getEnergy() - sent);
		}
		else if(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem)
		{
			IEnergyContainerItem item = (IEnergyContainerItem)itemstack.getItem();

			int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemstack)), item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack)));
			int toTransfer = (int)Math.round(Math.min(itemEnergy, (getEnergy()*general.TO_TE)));

			setEnergy(getEnergy() - (item.receiveEnergy(itemstack, toTransfer, false)*general.FROM_TE));
		}
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:25,代码来源:TileEntityChargepad.java

示例2: getPickBlock

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
	TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z);
	ItemStack itemStack = new ItemStack(MekanismBlocks.EnergyCube);

	IEnergyCube energyCube = (IEnergyCube)itemStack.getItem();
	energyCube.setEnergyCubeTier(itemStack, tileEntity.tier);

	IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem();
	energizedItem.setEnergy(itemStack, tileEntity.electricityStored);

	ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem();
	inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack);

	return itemStack;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:18,代码来源:BlockEnergyCube.java

示例3: getSubItems

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
@Override
public void getSubItems(Item item, CreativeTabs tabs, List<ItemStack> list)
{
	ItemStack discharged = new ItemStack(this);
	list.add(discharged);
	ItemStack charged = new ItemStack(this);
	setEnergy(charged, ((IEnergizedItem)charged.getItem()).getMaxEnergy(charged));
	list.add(charged);
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:10,代码来源:ItemEnergized.java

示例4: tryOpen

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
public void tryOpen()
{
	if(passwordField.getText() == null || passwordField.getText() == "")
	{
		displayText = EnumColor.DARK_RED + MekanismUtils.localize("gui.password.fieldsEmpty");
		SoundHandler.playSound("mekanism:etc.Error");
		ticker = 30;
	}
	else if(!getPassword().equals(passwordField.getText()))
	{
		displayText = EnumColor.DARK_RED + MekanismUtils.localize("gui.password.invalid");
		passwordField.setText("");
		SoundHandler.playSound("mekanism:etc.Error");
		ticker = 30;
	}
	else {
		if(isBlock)
		{
			tileEntity.setEnergy(tileEntity.getEnergy() - 100);
			Mekanism.packetHandler.sendToServer(new ElectricChestMessage(ElectricChestPacketType.SERVER_OPEN, true, true, 0, 0, null, Coord4D.get(tileEntity)));
		}
		else {
			((IEnergizedItem)itemStack.getItem()).setEnergy(itemStack, ((IEnergizedItem)itemStack.getItem()).getEnergy(itemStack) - 100);
			Mekanism.packetHandler.sendToServer(new ElectricChestMessage(ElectricChestPacketType.SERVER_OPEN, true, false, 0, 0, null, null));
		}

		SoundHandler.playSound("mekanism:etc.Success");
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:30,代码来源:GuiPasswordEnter.java

示例5: getScale

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
public int getScale()
{
	if(isBlock)
	{
		return tileEntity.getScaledEnergyLevel(52);
	}
	else {
		ItemStack stack = mc.thePlayer.getCurrentEquippedItem();
		return (int)(((IEnergizedItem)stack.getItem()).getEnergy(stack)*52 / ((IEnergizedItem)stack.getItem()).getMaxEnergy(stack));
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:12,代码来源:GuiElectricChest.java

示例6: getEnergy

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
public double getEnergy()
{
	if(isBlock)
	{
		return tileEntity.getEnergy();
	}
	else {
		ItemStack stack = mc.thePlayer.getCurrentEquippedItem();
		return ((IEnergizedItem)stack.getItem()).getEnergy(stack);
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:12,代码来源:GuiElectricChest.java

示例7: getManager

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
public static IC2ItemManager getManager(IEnergizedItem item)
{
	IC2ItemManager manager = new IC2ItemManager();
	manager.energizedItem = item;

	return manager;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:8,代码来源:IC2ItemManager.java

示例8: getSubItems

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
@Override
public void getSubItems(Item item, CreativeTabs tabs, List list)
{
	ItemStack discharged = new ItemStack(this);
	discharged.setItemDamage(100);
	list.add(discharged);
	ItemStack charged = new ItemStack(this);
	setEnergy(charged, ((IEnergizedItem)charged.getItem()).getMaxEnergy(charged));
	list.add(charged);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:11,代码来源:ItemEnergized.java

示例9: charge

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
/**
 * Universally charges an item, and updates the TileEntity's energy level.
 * @param slotID - ID of the slot of which to discharge
 * @param storer - TileEntity the item is being discharged in
 */
public static void charge(int slotID, IStrictEnergyStorage storer)
{
	IInventory inv = (TileEntityContainerBlock)storer;
	
	if(inv.getStackInSlot(slotID) != null && storer.getEnergy() > 0)
	{
		if(inv.getStackInSlot(slotID).getItem() instanceof IEnergizedItem)
		{
			storer.setEnergy(storer.getEnergy() - EnergizedItemManager.charge(inv.getStackInSlot(slotID), storer.getEnergy()));
		}
		else if(MekanismUtils.useIC2() && inv.getStackInSlot(slotID).getItem() instanceof IElectricItem)
		{
			double sent = ElectricItem.manager.charge(inv.getStackInSlot(slotID), (int)(storer.getEnergy()* general.TO_IC2), 4, true, false)* general.FROM_IC2;
			storer.setEnergy(storer.getEnergy() - sent);
		}
		else if(MekanismUtils.useRF() && inv.getStackInSlot(slotID).getItem() instanceof IEnergyContainerItem)
		{
			ItemStack itemStack = inv.getStackInSlot(slotID);
			IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(slotID).getItem();

			int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getMaxEnergyStored(itemStack) - item.getEnergyStored(itemStack)));
			int toTransfer = (int)Math.round(Math.min(itemEnergy, (storer.getEnergy()* general.TO_TE)));

			storer.setEnergy(storer.getEnergy() - (item.receiveEnergy(itemStack, toTransfer, false)* general.FROM_TE));
		}
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:33,代码来源:ChargeUtils.java

示例10: canBeDischarged

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
/**
 * Whether or not a defined ItemStack can be discharged for energy in some way.
 * @param itemstack - ItemStack to check
 * @return if the ItemStack can be discharged
 */
public static boolean canBeDischarged(ItemStack itemstack)
{
	return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) ||
			(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) ||
			(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) ||
			itemstack.getItem() == Items.redstone;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:13,代码来源:ChargeUtils.java

示例11: canBeCharged

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
/**
 * Whether or not a defined ItemStack can be charged with energy in some way.
 * @param itemstack - ItemStack to check
 * @return if the ItemStack can be discharged
 */
public static boolean canBeCharged(ItemStack itemstack)
{
	return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) ||
			(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canReceive(itemstack)) ||
			(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0);
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:12,代码来源:ChargeUtils.java

示例12: getPickBlock

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
	TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(x, y, z);
	ItemStack itemStack = new ItemStack(GeneratorsBlocks.Generator, 1, world.getBlockMetadata(x, y, z));

	if(tileEntity == null)
	{
		return null;
	}

	IEnergizedItem electricItem = (IEnergizedItem)itemStack.getItem();
	electricItem.setEnergy(itemStack, tileEntity.electricityStored);

	ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem();
	inventory.setInventory(tileEntity.getInventory(), itemStack);
	
	if(tileEntity instanceof ISustainedData)
	{
		((ISustainedData)tileEntity).writeSustainedData(itemStack);
	}

	if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack))
	{
		if(tileEntity instanceof ISustainedTank)
		{
			if(((ISustainedTank)tileEntity).getFluidStack() != null)
			{
				((ISustainedTank)itemStack.getItem()).setFluidStack(((ISustainedTank)tileEntity).getFluidStack(), itemStack);
			}
		}
	}

	return itemStack;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:36,代码来源:BlockGenerator.java

示例13: areItemsEqual

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
public static boolean areItemsEqual(ItemStack target, ItemStack input)
{
	if(target == null && input != null || target != null && input == null)
	{
		return false;
	}
	else if(target == null && input == null)
	{
		return true;
	}

	if(target.getItem() != input.getItem())
	{
		return false;
	}

	if(!(target.getItem() instanceof IEnergizedItem) && !(input.getItem() instanceof IEnergizedItem) && !(target.getItem() instanceof IGasItem) && !(input.getItem() instanceof IGasItem))
	{
		if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
		{
			return false;
		}
	}
	else {
		if(target.getItem() instanceof IEnergizedItem && input.getItem() instanceof IEnergizedItem)
		{
			if(((IEnergizedItem)target.getItem()).isMetadataSpecific(target) && ((IEnergizedItem)input.getItem()).isMetadataSpecific(input))
			{
				if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
				{
					return false;
				}
			}
		}
		
		if(target.getItem() instanceof IGasItem && input.getItem() instanceof IGasItem)
		{
			if(((IGasItem)target.getItem()).isMetadataSpecific(target) && ((IGasItem)input.getItem()).isMetadataSpecific(input))
			{
				if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
				{
					return false;
				}
			}
		}

		if(target.getItem() instanceof IEnergyCube && input.getItem() instanceof IEnergyCube)
		{
			if(((IEnergyCube)target.getItem()).getEnergyCubeTier(target) != ((IEnergyCube)input.getItem()).getEnergyCubeTier(input))
			{
				return false;
			}
		}
		else if(target.getItem() instanceof ItemBlockBasic && input.getItem() instanceof ItemBlockBasic)
		{
			if(((ItemBlockBasic)target.getItem()).getTier(target) != ((ItemBlockBasic)input.getItem()).getTier(input))
			{
				return false;
			}
		}
		else if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory)
		{
			if(isFactory(target) && isFactory(input))
			{
				if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input))
				{
					return false;
				}
			}
		}
	}

	return true;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:75,代码来源:MekanismRecipeHandler.java

示例14: checkItemEquals

import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
private boolean checkItemEquals(ItemStack target, ItemStack input)
{
	if(input == null && target != null || input != null && target == null)
	{
		return false;
	}
	else if(input == null && target == null)
	{
		return true;
	}

	if(target.getItem() != input.getItem())
	{
		return false;
	}

	if(!(target.getItem() instanceof IEnergizedItem) && !(input.getItem() instanceof IEnergizedItem) && !(target.getItem() instanceof IGasItem) && !(input.getItem() instanceof IGasItem))
	{
		if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
		{
			return false;
		}
	}
	else {
		if(target.getItem() instanceof IEnergizedItem && input.getItem() instanceof IEnergizedItem)
		{
			if(((IEnergizedItem)target.getItem()).isMetadataSpecific(target) && ((IEnergizedItem)input.getItem()).isMetadataSpecific(input))
			{
				if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
				{
					return false;
				}
			}
		}
		
		if(target.getItem() instanceof IGasItem && input.getItem() instanceof IGasItem)
		{
			if(((IGasItem)target.getItem()).isMetadataSpecific(target) && ((IGasItem)input.getItem()).isMetadataSpecific(input))
			{
				if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE)
				{
					return false;
				}
			}
		}

		if(target.getItem() instanceof IEnergyCube && input.getItem() instanceof IEnergyCube)
		{
			if(((IEnergyCube)target.getItem()).getEnergyCubeTier(target) != ((IEnergyCube)input.getItem()).getEnergyCubeTier(input))
			{
				return false;
			}
		}
		else if(target.getItem() instanceof ItemBlockBasic && input.getItem() instanceof ItemBlockBasic)
		{
			if(((ItemBlockBasic)target.getItem()).getTier(target) != ((ItemBlockBasic)input.getItem()).getTier(input))
			{
				return false;
			}
		}
		else if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory)
		{
			if(isFactory(target) && isFactory(input))
			{
				if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input))
				{
					return false;
				}
			}
		}
	}

	return true;
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:75,代码来源:MekanismRecipe.java


注:本文中的mekanism.api.energy.IEnergizedItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。