From 6d242b08d58355d24b0a385767e7633c75084410 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Fri, 25 May 2018 12:12:59 +0300 Subject: [PATCH] Nano Saber energy storage is now configurable. --- .../techreborn/config/ConfigTechReborn.java | 3 +++ .../techreborn/items/tools/ItemNanosaber.java | 21 +++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/techreborn/config/ConfigTechReborn.java b/src/main/java/techreborn/config/ConfigTechReborn.java index 3ced8991d..d13bae2e5 100644 --- a/src/main/java/techreborn/config/ConfigTechReborn.java +++ b/src/main/java/techreborn/config/ConfigTechReborn.java @@ -39,6 +39,9 @@ public class ConfigTechReborn { @ConfigRegistry(config = "misc", category = "general", key = "enableGemTools", comment = "Enable Gem armor and tools") public static boolean enableGemArmorAndTools = true; + @ConfigRegistry(config = "items", category = "power", key = "nanoSaberCharge", comment = "Energy Capacity for Nano Saber (FE)") + public static int nanoSaberCharge = 640_000; + @ConfigRegistry(config = "items", category = "power", key = "ironDrillCharge", comment = "Energy Capacity for Iron Drill (FE)") public static int IronDrillCharge = 40_000; diff --git a/src/main/java/techreborn/items/tools/ItemNanosaber.java b/src/main/java/techreborn/items/tools/ItemNanosaber.java index 7c3335e35..81a1f4bd7 100644 --- a/src/main/java/techreborn/items/tools/ItemNanosaber.java +++ b/src/main/java/techreborn/items/tools/ItemNanosaber.java @@ -55,6 +55,7 @@ import reborncore.common.powerSystem.forge.ForgePowerItemManager; import reborncore.common.util.ChatUtils; import reborncore.common.util.ItemUtils; import techreborn.client.TechRebornCreativeTab; +import techreborn.config.ConfigTechReborn; import techreborn.init.ModItems; import techreborn.lib.MessageIDs; @@ -62,6 +63,7 @@ import javax.annotation.Nullable; import java.util.List; public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { + public static final int maxCharge = ConfigTechReborn.nanoSaberCharge; public int cost = 250; public ItemNanosaber() { @@ -74,7 +76,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { @Override @SideOnly(Side.CLIENT) public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) { - if (isActive(stack)) { + if (ItemUtils.isActive(stack)) { ForgePowerItemManager capEnergy = (ForgePowerItemManager) stack.getCapability(CapabilityEnergy.ENERGY, null); if (capEnergy.getMaxEnergyStored() - capEnergy.getEnergyStored() >= 0.9 * capEnergy.getMaxEnergyStored()) { return 0.5F; @@ -86,13 +88,6 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { }); } - private boolean isActive(ItemStack stack) { - if (!stack.isEmpty() && stack.getTagCompound() != null && stack.getTagCompound().getBoolean("isActive")) { - return true; - } - return false; - } - // ItemSword @Override public boolean hitEntity(ItemStack stack, EntityLivingBase entityliving, EntityLivingBase entityliving1) { @@ -110,7 +105,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { Multimap multimap = HashMultimap.create(); int modifier = 0; - if (isActive(stack)) { + if (ItemUtils.isActive(stack)) { modifier = 9; } if (slot == EntityEquipmentSlot.MAINHAND) { @@ -132,7 +127,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { + TextFormatting.GOLD + I18n .format("techreborn.message.nanosaberActivate"))); } else { - if (!isActive(stack)) { + if (!ItemUtils.isActive(stack)) { if (stack.getTagCompound() == null) { stack.setTagCompound(new NBTTagCompound()); } @@ -160,7 +155,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { @Override public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { - if (isActive(stack) && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() < cost) { + if (ItemUtils.isActive(stack) && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() < cost) { if(worldIn.isRemote){ ChatUtils.sendNoSpamMessages(MessageIDs.nanosaberID, new TextComponentString( TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberEnergyError") + " " @@ -228,7 +223,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { @SideOnly(Side.CLIENT) @Override public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { - if (!isActive(stack)) { + if (!ItemUtils.isActive(stack)) { tooltip.add(TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberInactive")); } else { tooltip.add(TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberActive")); @@ -238,7 +233,7 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { // IEnergyItemInfo @Override public double getMaxPower(ItemStack stack) { - return 160_000; + return maxCharge; } @Override