Fix it so the packs charge things.

This commit is contained in:
Stuart Pomeroy 2016-03-29 09:43:07 +01:00
parent 58902f3901
commit 3282677f02
2 changed files with 25 additions and 12 deletions

View file

@ -93,23 +93,17 @@ public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITex
return 1 - charge;
}
@Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{System.out.print("Hey!");
}
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
{
System.out.print("Hey!");
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
if(player.inventory.getStackInSlot(i) != null){
ItemStack item = player.inventory.getStackInSlot(i);
if(item.getItem() instanceof IEnergyItemInfo){
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();
if(energyItemInfo.canAcceptEnergy(item)){
if(energyItemInfo.getMaxPower(item) != PoweredItem.getEnergy(item)){
if(PoweredItem.canUseEnergy(energyItemInfo.getMaxPower(item), itemStack)){
PoweredItem.useEnergy(energyItemInfo.getMaxPower(item), itemStack);
PoweredItem.addEnergy(energyItemInfo.getMaxPower(item), item);
PoweredItem.useEnergy(energyItemInfo.getMaxTransfer(item), itemStack);
PoweredItem.setEnergy(PoweredItem.getEnergy(item) + energyItemInfo.getMaxTransfer(item), item);
}
}
}
@ -135,6 +129,7 @@ public class ItemLapotronPack extends ItemArmor implements IEnergyItemInfo, ITex
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)

View file

@ -1,7 +1,5 @@
package techreborn.items.armor;
import java.util.List;
import me.modmuss50.jsonDestroyer.api.ITexturedItem;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
@ -11,6 +9,7 @@ import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.RebornCore;
@ -20,6 +19,8 @@ import techreborn.client.TechRebornCreativeTab;
import techreborn.config.ConfigTechReborn;
import techreborn.lib.ModInfo;
import java.util.List;
public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo, ITexturedItem
{
@ -35,7 +36,23 @@ public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo, IT
setCreativeTab(TechRebornCreativeTab.instance);
RebornCore.jsonDestroyer.registerObject(this);
}
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack)
{
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
if(player.inventory.getStackInSlot(i) != null){
ItemStack item = player.inventory.getStackInSlot(i);
if(item.getItem() instanceof IEnergyItemInfo){
IEnergyItemInfo energyItemInfo = (IEnergyItemInfo) item.getItem();
if(energyItemInfo.getMaxPower(item) != PoweredItem.getEnergy(item)){
if(PoweredItem.canUseEnergy(energyItemInfo.getMaxPower(item), itemStack)){
PoweredItem.useEnergy(energyItemInfo.getMaxTransfer(item), itemStack);
PoweredItem.setEnergy(PoweredItem.getEnergy(item) + energyItemInfo.getMaxTransfer(item), item);
}
}
}
}
}
}
@Override
@SideOnly(Side.CLIENT)
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
@ -118,4 +135,5 @@ public class ItemLithiumBatpack extends ItemArmor implements IEnergyItemInfo, IT
return new ModelResourceLocation(ModInfo.MOD_ID + ":" + getUnlocalizedName(stack).substring(5), "inventory");
}
}