Remaining changes for powered items.

This commit is contained in:
drcrazy 2018-05-23 00:36:11 +03:00
parent f203bbbefd
commit ff18e28d1c
8 changed files with 33 additions and 17 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);