From ff18e28d1cd8022efb9a15f5300c6945fafe7115 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Wed, 23 May 2018 00:36:11 +0300 Subject: [PATCH] Remaining changes for powered items. --- .../java/techreborn/items/tools/ItemAdvancedDrill.java | 8 +++++--- .../techreborn/items/tools/ItemAdvancedJackhammer.java | 6 ++++-- .../java/techreborn/items/tools/ItemDiamondChainsaw.java | 6 ++++-- .../java/techreborn/items/tools/ItemDiamondDrill.java | 6 ++++-- .../techreborn/items/tools/ItemDiamondJackhammer.java | 6 ++++-- .../java/techreborn/items/tools/ItemSteelChainsaw.java | 6 ++++-- src/main/java/techreborn/items/tools/ItemSteelDrill.java | 6 ++++-- .../java/techreborn/items/tools/ItemSteelJackhammer.java | 6 ++++-- 8 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java b/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java index 0611a3cbe..9cf9ef596 100644 --- a/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java +++ b/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java @@ -36,9 +36,10 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -94,7 +95,7 @@ public class ItemAdvancedDrill extends ItemDrill { public void breakBlock(BlockPos pos, World world, EntityPlayer playerIn, ItemStack drill) { IBlockState blockState = world.getBlockState(pos); - PoweredItem.useEnergy(cost, drill); + drill.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy(cost, false); blockState.getBlock().harvestBlock(world, playerIn, pos, blockState, world.getTileEntity(pos), drill); world.setBlockToAir(pos); world.removeTileEntity(pos); @@ -152,7 +153,8 @@ public class ItemAdvancedDrill extends ItemDrill { ItemStack stack = new ItemStack(ModItems.ADVANCED_DRILL); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged); diff --git a/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java b/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java index 81365077f..cc698947c 100644 --- a/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java +++ b/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java @@ -27,9 +27,10 @@ package techreborn.items.tools; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -51,7 +52,8 @@ public class ItemAdvancedJackhammer extends ItemJackhammer { ItemStack stack = new ItemStack(ModItems.ADVANCED_JACKHAMMER); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged); diff --git a/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java b/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java index c9141ebd8..66cd1b9b2 100644 --- a/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java +++ b/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java @@ -29,9 +29,10 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -52,7 +53,8 @@ public class ItemDiamondChainsaw extends ItemChainsaw { ItemStack stack = new ItemStack(ModItems.DIAMOND_CHAINSAW); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged); diff --git a/src/main/java/techreborn/items/tools/ItemDiamondDrill.java b/src/main/java/techreborn/items/tools/ItemDiamondDrill.java index 850233ebe..cb7c20e29 100644 --- a/src/main/java/techreborn/items/tools/ItemDiamondDrill.java +++ b/src/main/java/techreborn/items/tools/ItemDiamondDrill.java @@ -29,9 +29,10 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -52,7 +53,8 @@ public class ItemDiamondDrill extends ItemDrill { ItemStack stack = new ItemStack(ModItems.DIAMOND_DRILL); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged); diff --git a/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java b/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java index 2c2f4c06d..14751def8 100644 --- a/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java +++ b/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java @@ -27,9 +27,10 @@ package techreborn.items.tools; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -50,7 +51,8 @@ public class ItemDiamondJackhammer extends ItemJackhammer { ItemStack stack = new ItemStack(ModItems.DIAMOND_JACKHAMMER); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged); diff --git a/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java b/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java index eb7942079..f19213b4e 100644 --- a/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java +++ b/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java @@ -29,9 +29,10 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -53,7 +54,8 @@ public class ItemSteelChainsaw extends ItemChainsaw { ItemStack stack = new ItemStack(ModItems.STEEL_CHAINSAW); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged); diff --git a/src/main/java/techreborn/items/tools/ItemSteelDrill.java b/src/main/java/techreborn/items/tools/ItemSteelDrill.java index 3fc14b253..c2a7bc4bc 100644 --- a/src/main/java/techreborn/items/tools/ItemSteelDrill.java +++ b/src/main/java/techreborn/items/tools/ItemSteelDrill.java @@ -29,9 +29,10 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -53,7 +54,8 @@ public class ItemSteelDrill extends ItemDrill { ItemStack stack = new ItemStack(ModItems.STEEL_DRILL); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged); diff --git a/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java b/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java index 37492fe19..f55c41df6 100644 --- a/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java +++ b/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java @@ -27,9 +27,10 @@ package techreborn.items.tools; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; +import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import reborncore.common.powerSystem.PoweredItem; +import reborncore.common.powerSystem.forge.ForgePowerItemManager; import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; @@ -51,7 +52,8 @@ public class ItemSteelJackhammer extends ItemJackhammer { ItemStack stack = new ItemStack(ModItems.STEEL_JACKHAMMER); ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); - PoweredItem.setEnergy(getMaxPower(charged), charged); + ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); + capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); itemList.add(uncharged); itemList.add(charged);