本文整理汇总了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));
}
}
}
示例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;
}
示例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);
}
示例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");
}
}
示例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));
}
}
示例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);
}
}
示例7: getManager
import mekanism.api.energy.IEnergizedItem; //导入依赖的package包/类
public static IC2ItemManager getManager(IEnergizedItem item)
{
IC2ItemManager manager = new IC2ItemManager();
manager.energizedItem = item;
return manager;
}
示例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);
}
示例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));
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}