diff --git a/src/main/java/techreborn/client/gui/GuiFusionReactor.java b/src/main/java/techreborn/client/gui/GuiFusionReactor.java index 9715c4f33..85674be70 100644 --- a/src/main/java/techreborn/client/gui/GuiFusionReactor.java +++ b/src/main/java/techreborn/client/gui/GuiFusionReactor.java @@ -33,6 +33,7 @@ import reborncore.client.multiblock.Multiblock; import reborncore.client.multiblock.MultiblockRenderEvent; import reborncore.client.multiblock.MultiblockSet; import reborncore.common.network.NetworkManager; +import reborncore.common.powerSystem.PowerSystem; import reborncore.common.util.Torus; import techreborn.client.gui.widget.GuiButtonHologram; import techreborn.client.gui.widget.GuiButtonUpDown; @@ -85,7 +86,7 @@ public class GuiFusionReactor extends GuiBase { builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer); drawCentredString(tile.getStateString(), 20, Color.BLUE.darker().getRGB(), layer); if(tile.state == 2){ - drawCentredString( tile.getLocaliszedPowerFormatted((int) tile.getPowerChange()) + "/t", 30, Color.GREEN.darker().getRGB(), layer); + drawCentredString( PowerSystem.getLocaliszedPowerFormatted((int) tile.getPowerChange()) + "/t", 30, Color.GREEN.darker().getRGB(), layer); } } else { builder.drawMultiblockMissingBar(this, layer); diff --git a/src/main/java/techreborn/items/tools/ItemAdvancedChainsaw.java b/src/main/java/techreborn/items/tools/ItemAdvancedChainsaw.java index 4b5b3f8fb..f8de37fa9 100644 --- a/src/main/java/techreborn/items/tools/ItemAdvancedChainsaw.java +++ b/src/main/java/techreborn/items/tools/ItemAdvancedChainsaw.java @@ -56,12 +56,11 @@ public class ItemAdvancedChainsaw extends ItemChainsaw { return; } ItemStack stack = new ItemStack(ModItems.ADVANCED_CHAINSAW); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } diff --git a/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java b/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java index 9cf9ef596..156bd3456 100644 --- a/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java +++ b/src/main/java/techreborn/items/tools/ItemAdvancedDrill.java @@ -151,12 +151,11 @@ public class ItemAdvancedDrill extends ItemDrill { return; } ItemStack stack = new ItemStack(ModItems.ADVANCED_DRILL); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } } diff --git a/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java b/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java index cc698947c..0d027f369 100644 --- a/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java +++ b/src/main/java/techreborn/items/tools/ItemAdvancedJackhammer.java @@ -50,12 +50,11 @@ public class ItemAdvancedJackhammer extends ItemJackhammer { return; } ItemStack stack = new ItemStack(ModItems.ADVANCED_JACKHAMMER); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } } diff --git a/src/main/java/techreborn/items/tools/ItemCloakingDevice.java b/src/main/java/techreborn/items/tools/ItemCloakingDevice.java index 308b014ea..26247a3e0 100644 --- a/src/main/java/techreborn/items/tools/ItemCloakingDevice.java +++ b/src/main/java/techreborn/items/tools/ItemCloakingDevice.java @@ -57,7 +57,7 @@ import javax.annotation.Nullable; @RebornRegistry(modID = ModInfo.MOD_ID) public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo { - @ConfigRegistry(config = "items", category = "cloacking_device", key = "ClockingDeviceEnergyUsage", comment = "Cloacking device energy usesage (Value in EU)") + @ConfigRegistry(config = "items", category = "cloacking_device", key = "ClockingDeviceEnergyUsage", comment = "Cloacking device energy usesage (Value in FE)") public static int usage = 10; public static int MaxCharge = ConfigTechReborn.CloakingDeviceCharge; diff --git a/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java b/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java index 66cd1b9b2..8203a8c0c 100644 --- a/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java +++ b/src/main/java/techreborn/items/tools/ItemDiamondChainsaw.java @@ -39,8 +39,7 @@ import techreborn.init.ModItems; public class ItemDiamondChainsaw extends ItemChainsaw { public ItemDiamondChainsaw() { - super(ToolMaterial.DIAMOND, "techreborn.diamondChainsaw", ConfigTechReborn.DiamondChainsawCharge, - 1.0F); + super(ToolMaterial.DIAMOND, "techreborn.diamondChainsaw", ConfigTechReborn.DiamondChainsawCharge, 1.0F); this.cost = 250; } @@ -51,12 +50,11 @@ public class ItemDiamondChainsaw extends ItemChainsaw { return; } ItemStack stack = new ItemStack(ModItems.DIAMOND_CHAINSAW); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } diff --git a/src/main/java/techreborn/items/tools/ItemDiamondDrill.java b/src/main/java/techreborn/items/tools/ItemDiamondDrill.java index cb7c20e29..8020e8a3b 100644 --- a/src/main/java/techreborn/items/tools/ItemDiamondDrill.java +++ b/src/main/java/techreborn/items/tools/ItemDiamondDrill.java @@ -39,8 +39,7 @@ import techreborn.init.ModItems; public class ItemDiamondDrill extends ItemDrill { public ItemDiamondDrill() { - super(ToolMaterial.DIAMOND, "techreborn.diamondDrill", ConfigTechReborn.DiamondDrillCharge, - 0.5F, 15F); + super(ToolMaterial.DIAMOND, "techreborn.diamondDrill", ConfigTechReborn.DiamondDrillCharge, 0.5F, 15F); this.cost = 250; } @@ -51,12 +50,11 @@ public class ItemDiamondDrill extends ItemDrill { return; } ItemStack stack = new ItemStack(ModItems.DIAMOND_DRILL); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } diff --git a/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java b/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java index 14751def8..c5281b4b4 100644 --- a/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java +++ b/src/main/java/techreborn/items/tools/ItemDiamondJackhammer.java @@ -49,12 +49,11 @@ public class ItemDiamondJackhammer extends ItemJackhammer { return; } ItemStack stack = new ItemStack(ModItems.DIAMOND_JACKHAMMER); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } } diff --git a/src/main/java/techreborn/items/tools/ItemElectricTreetap.java b/src/main/java/techreborn/items/tools/ItemElectricTreetap.java index 2b5a458aa..74742babb 100644 --- a/src/main/java/techreborn/items/tools/ItemElectricTreetap.java +++ b/src/main/java/techreborn/items/tools/ItemElectricTreetap.java @@ -59,7 +59,7 @@ import javax.annotation.Nullable; */ public class ItemElectricTreetap extends ItemTR implements IEnergyItemInfo { - public static final int maxCharge = 10000; + public static final int maxCharge = 10_000; public static final int tier = 1; public int cost = 20; diff --git a/src/main/java/techreborn/items/tools/ItemRockCutter.java b/src/main/java/techreborn/items/tools/ItemRockCutter.java index 32e1d9284..83923924d 100644 --- a/src/main/java/techreborn/items/tools/ItemRockCutter.java +++ b/src/main/java/techreborn/items/tools/ItemRockCutter.java @@ -95,12 +95,7 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo { } @Override - public int getHarvestLevel(ItemStack stack, - String toolClass, - @Nullable - EntityPlayer player, - @Nullable - IBlockState blockState) { + public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState) { if (!stack.isItemEnchanted()) { stack.addEnchantment(Enchantments.SILK_TOUCH, 1); } @@ -135,9 +130,7 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo { @Override @Nullable - public ICapabilityProvider initCapabilities(ItemStack stack, - @Nullable - NBTTagCompound nbt) { + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { return new PoweredItemContainerProvider(stack); } diff --git a/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java b/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java index f19213b4e..d8103aa8c 100644 --- a/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java +++ b/src/main/java/techreborn/items/tools/ItemSteelChainsaw.java @@ -39,8 +39,7 @@ import techreborn.init.ModItems; public class ItemSteelChainsaw extends ItemChainsaw { public ItemSteelChainsaw() { - super(ToolMaterial.IRON, "techreborn.ironChainsaw", ConfigTechReborn.IronChainsawCharge, - 0.5F); + super(ToolMaterial.IRON, "techreborn.ironChainsaw", ConfigTechReborn.IronChainsawCharge, 0.5F); this.cost = 50; } @@ -52,12 +51,11 @@ public class ItemSteelChainsaw extends ItemChainsaw { return; } ItemStack stack = new ItemStack(ModItems.STEEL_CHAINSAW); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } diff --git a/src/main/java/techreborn/items/tools/ItemSteelDrill.java b/src/main/java/techreborn/items/tools/ItemSteelDrill.java index c2a7bc4bc..eacfc195d 100644 --- a/src/main/java/techreborn/items/tools/ItemSteelDrill.java +++ b/src/main/java/techreborn/items/tools/ItemSteelDrill.java @@ -39,8 +39,7 @@ import techreborn.init.ModItems; public class ItemSteelDrill extends ItemDrill { public ItemSteelDrill() { - super(ToolMaterial.IRON, "techreborn.ironDrill", ConfigTechReborn.IronDrillCharge, - 0.5F, 10F); + super(ToolMaterial.IRON, "techreborn.ironDrill", ConfigTechReborn.IronDrillCharge, 0.5F, 10F); this.cost = 50; } @@ -52,12 +51,11 @@ public class ItemSteelDrill extends ItemDrill { return; } ItemStack stack = new ItemStack(ModItems.STEEL_DRILL); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } diff --git a/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java b/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java index f55c41df6..74b175c21 100644 --- a/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java +++ b/src/main/java/techreborn/items/tools/ItemSteelJackhammer.java @@ -44,18 +44,16 @@ public class ItemSteelJackhammer extends ItemJackhammer { @SideOnly(Side.CLIENT) @Override - public void getSubItems( - CreativeTabs par2CreativeTabs, NonNullList itemList) { + public void getSubItems( CreativeTabs par2CreativeTabs, NonNullList itemList) { if (!isInCreativeTab(par2CreativeTabs)) { return; } ItemStack stack = new ItemStack(ModItems.STEEL_JACKHAMMER); - ItemStack uncharged = stack.copy(); ItemStack charged = stack.copy(); ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null); capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored()); - itemList.add(uncharged); + itemList.add(stack); itemList.add(charged); } } diff --git a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java index fd01001a2..9cc6c3d0d 100644 --- a/src/main/java/techreborn/tiles/generator/TileSolarPanel.java +++ b/src/main/java/techreborn/tiles/generator/TileSolarPanel.java @@ -32,6 +32,7 @@ import net.minecraft.util.Rotation; import net.minecraft.util.text.TextFormatting; import reborncore.api.IToolDrop; import reborncore.api.power.EnumPowerTier; +import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.util.StringUtils; import techreborn.Core; @@ -157,13 +158,13 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop { @Override public void addInfo(List info, boolean isRealTile) { info.add(TextFormatting.GRAY + "Internal Energy Storage: " + TextFormatting.GOLD - + getLocaliszedPowerFormatted((int) getMaxPower())); + + PowerSystem.getLocaliszedPowerFormatted((int) getMaxPower())); info.add(TextFormatting.GRAY + "Generation Rate Day: " + TextFormatting.GOLD - + getLocaliszedPowerFormatted(panel.generationRateD)); + + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD)); info.add(TextFormatting.GRAY + "Generation Rate Night: " + TextFormatting.GOLD - + getLocaliszedPowerFormatted(panel.generationRateN)); + + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN)); info.add(TextFormatting.GRAY + "Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(getTier().toString())); } diff --git a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java index 378d6f17a..bd2787ff7 100644 --- a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java +++ b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java @@ -32,6 +32,7 @@ import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import reborncore.api.IToolDrop; import reborncore.api.power.EnumPowerTier; +import reborncore.api.power.IEnergyItemInfo; import reborncore.api.tile.IInventoryProvider; import reborncore.common.RebornCoreConfig; import reborncore.common.powerSystem.TilePowerAcceptor; @@ -71,27 +72,20 @@ public class TileEnergyStorage extends TilePowerAcceptor super.update(); if (!inventory.getStackInSlot(0).isEmpty()) { ItemStack stack = inventory.getStackInSlot(0); - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ - IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(getEnergy() > 0 && energyStorage.getEnergyStored() < energyStorage.getMaxEnergyStored()){ - energyStorage.receiveEnergy((int) useEnergy(getMaxOutput()) * RebornCoreConfig.euPerFU, false); + if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) { + IEnergyStorage powerItem = stack.getCapability(CapabilityEnergy.ENERGY, null); + int maxReceive = Math.min((powerItem.getMaxEnergyStored() - powerItem.getEnergyStored()), + (int) ((IEnergyItemInfo) stack.getItem()).getMaxTransfer(stack)); + double maxUse = Math.min((double) (maxReceive / RebornCoreConfig.euPerFU), getMaxOutput()); + if (getEnergy() >= 0.0 && maxReceive > 0) { + powerItem.receiveEnergy((int) useEnergy(maxUse) * RebornCoreConfig.euPerFU, false); } - } - if(CompatManager.isIC2Loaded){ + } else if (CompatManager.isIC2Loaded) { IC2ItemCharger.chargeIc2Item(this, stack); } } if (!inventory.getStackInSlot(1).isEmpty()) { - ItemStack stack = inventory.getStackInSlot(1); - if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){ - IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null); - if(getEnergy() != getMaxPower() && energyStorage.getEnergyStored() > 0){ - addEnergy(energyStorage.extractEnergy((int) (getMaxInput() * RebornCoreConfig.euPerFU), false) / RebornCoreConfig.euPerFU); - } - } - if(CompatManager.isIC2Loaded){ - IC2ItemCharger.dischargeIc2Item(this, stack); - } + charge(1); } } diff --git a/src/main/java/techreborn/tiles/transformers/TileTransformer.java b/src/main/java/techreborn/tiles/transformers/TileTransformer.java index 37d161d3f..04078b304 100644 --- a/src/main/java/techreborn/tiles/transformers/TileTransformer.java +++ b/src/main/java/techreborn/tiles/transformers/TileTransformer.java @@ -32,6 +32,7 @@ import net.minecraft.util.text.TextFormatting; import reborncore.api.IListInfoProvider; import reborncore.api.IToolDrop; import reborncore.api.power.EnumPowerTier; +import reborncore.common.powerSystem.PowerSystem; import reborncore.common.powerSystem.TilePowerAcceptor; import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.impl.ConfigRegistry; @@ -140,9 +141,9 @@ public class TileTransformer extends TilePowerAcceptor // IListInfoProvider @Override public void addInfo(List info, boolean isRealTile) { - info.add(TextFormatting.GRAY + "Input Rate: " + TextFormatting.GOLD + getLocaliszedPowerFormatted((int) getMaxInput())); + info.add(TextFormatting.GRAY + "Input Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxInput())); info.add(TextFormatting.GRAY + "Input Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(inputTier.toString())); - info.add(TextFormatting.GRAY + "Output Rate: " + TextFormatting.GOLD + getLocaliszedPowerFormatted((int) getMaxOutput())); + info.add(TextFormatting.GRAY + "Output Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxOutput())); info.add(TextFormatting.GRAY + "Output Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(ouputTier.toString())); }