From 1d3e62493db2e305f24fedc9452b82caa845ce69 Mon Sep 17 00:00:00 2001 From: OneEyeMaker Date: Sun, 5 Jun 2016 11:04:42 +0300 Subject: [PATCH] Added config options for armor. Now Draconic Armor doesn't require energy to extinguish player, because Wyvern Armor doesn't require energy to do it. --- .../common/handler/BalanceConfigHandler.java | 32 +++++++++++++++ .../items/armor/CustomArmorHandler.java | 29 +++++++------ .../common/items/armor/DraconicArmor.java | 41 +++++++++++++------ .../common/items/armor/ICustomArmor.java | 23 ++++++----- .../common/items/armor/WyvernArmor.java | 34 ++++++++++----- .../common/lib/References.java | 4 -- 6 files changed, 113 insertions(+), 50 deletions(-) diff --git a/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java index 42d5c552..70455be6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/handler/BalanceConfigHandler.java @@ -6,6 +6,15 @@ import net.minecraftforge.common.config.Configuration; public class BalanceConfigHandler { + public static int wyvernArmorBaseStorage = 1000000; + public static int wyvernArmorStoragePerUpgrade = 500000; + public static int wyvernArmorMaxTransfer = 50000; + public static int wyvernArmorEnergyPerProtectionPoint = 1000; + public static int draconicArmorBaseStorage = 10000000; + public static int draconicArmorStoragePerUpgrade = 5000000; + public static int draconicArmorMaxTransfer = 500000; + public static int draconicArmorEnergyPerProtectionPoint = 1000; + public static int draconicArmorEnergyToRemoveEffects = 5000; public static int wyvernToolsBaseStorage = 1000000; public static int wyvernToolsStoragePerUpgrade = 500000; public static int wyvernToolsMaxTransfer = 50000; @@ -43,6 +52,29 @@ public class BalanceConfigHandler } private static void syncConfig() { + wyvernArmorBaseStorage = + getInteger("energy.armor", "Wyvern Armor: Base energy storage (RF)", wyvernArmorBaseStorage); + wyvernArmorStoragePerUpgrade = + getInteger("energy.armor", "Wyvern Armor: Additional energy storage per upgrade installed (RF)", + wyvernArmorStoragePerUpgrade); + wyvernArmorMaxTransfer = + getInteger("energy.armor", "Wyvern Armor: Maximum energy transfer rate (RF/t)", wyvernArmorMaxTransfer); + wyvernArmorEnergyPerProtectionPoint = + getInteger("energy.armor", "Wyvern Armor: Amount of energy required to restore protection point (RF)", + wyvernArmorEnergyPerProtectionPoint); + draconicArmorBaseStorage = + getInteger("energy.armor", "Draconic Armor: Base energy storage (RF)", draconicArmorBaseStorage); + draconicArmorStoragePerUpgrade = + getInteger("energy.armor", "Draconic Armor: Additional energy storage per upgrade installed (RF)", + draconicArmorStoragePerUpgrade); + draconicArmorMaxTransfer = + getInteger("energy.armor", "Draconic Armor: Maximum energy transfer rate (RF/t)", draconicArmorMaxTransfer); + draconicArmorEnergyPerProtectionPoint = + getInteger("energy.armor", "Draconic Armor: Amount of energy required to restore protection point (RF)", + draconicArmorEnergyPerProtectionPoint); + draconicArmorEnergyToRemoveEffects = + getInteger("energy.armor", "Draconic Armor: Amount of energy required to remove negative effects (RF)", + draconicArmorEnergyToRemoveEffects); wyvernToolsBaseStorage = getInteger("energy.tools", "Wyvern Tools: Base energy storage (RF)", wyvernToolsBaseStorage); wyvernToolsStoragePerUpgrade = diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java index 9fea9af6..2eb4b1ea 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/CustomArmorHandler.java @@ -1,9 +1,12 @@ package com.brandon3055.draconicevolution.common.items.armor; +import java.util.*; + import cofh.api.energy.IEnergyContainerItem; import com.brandon3055.brandonscore.BrandonsCore; import com.brandon3055.brandonscore.common.utills.ItemNBTHelper; import com.brandon3055.draconicevolution.DraconicEvolution; +import com.brandon3055.draconicevolution.common.handler.BalanceConfigHandler; import com.brandon3055.draconicevolution.common.network.ShieldHitPacket; import com.brandon3055.draconicevolution.common.utills.IUpgradableItem; import com.brandon3055.draconicevolution.common.utills.LogHelper; @@ -23,8 +26,6 @@ import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingDeathEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; -import java.util.*; - /** * Created by Brandon on 13/11/2014. */ @@ -84,9 +85,12 @@ public class CustomArmorHandler { float hitAmount = ModHelper.applyModDamageAdjustments(summery, event); - if (applyArmorDamageBlocking(event, summery)) return; - - if (summery == null || summery.protectionPoints <= 0 || event.source == ADMIN_KILL) return; + if (applyArmorDamageBlocking(event, summery)) { + return; + } + if (summery == null || summery.protectionPoints <= 0 || event.source == ADMIN_KILL) { + return; + } event.setCanceled(true); //Ensure that the /kill command can still kill the player if (hitAmount == Float.MAX_VALUE && !event.source.damageType.equals(ADMIN_KILL.damageType)){ @@ -95,8 +99,6 @@ public class CustomArmorHandler { } if ((float)player.hurtResistantTime > (float)player.maxHurtResistantTime / 2.0F) return; - if (summery.protectionPoints <= 0) return; - float newEntropy = Math.min(summery.entropy + 1 + (hitAmount / 20), 100F); //Divide the damage between the armor peaces based on how many of the protection points each peace has @@ -158,11 +160,11 @@ public class CustomArmorHandler { } } - if (totalCharge < 10000000) return; + if (totalCharge < BalanceConfigHandler.draconicArmorBaseStorage) return; for (int i = 0; i < summery.armorStacks.length; i++){ if (summery.armorStacks[i] != null) { - ((IEnergyContainerItem)summery.armorStacks[i].getItem()).extractEnergy(summery.armorStacks[i], (int) ((charge[i] / (double) totalCharge) * 10000000), false); + ((IEnergyContainerItem)summery.armorStacks[i].getItem()).extractEnergy(summery.armorStacks[i], (int) ((charge[i] / (double) totalCharge) * BalanceConfigHandler.draconicArmorBaseStorage), false); } } @@ -185,7 +187,7 @@ public class CustomArmorHandler { float totalPointsToAdd = Math.min(summery.maxProtectionPoints - summery.protectionPoints, summery.maxProtectionPoints / 60F); totalPointsToAdd *= (1F - (summery.entropy / 100F)); - totalPointsToAdd = Math.min(totalPointsToAdd, summery.totalEnergyStored / 1000); + totalPointsToAdd = Math.min(totalPointsToAdd, summery.totalEnergyStored / (summery.hasDraconic ? BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint : BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint)); if (totalPointsToAdd < 0F) totalPointsToAdd = 0F; summery.entropy -= (summery.meanRecoveryPoints * 0.01F); @@ -195,7 +197,8 @@ public class CustomArmorHandler { ItemStack stack = summery.armorStacks[i]; if (stack == null || summery.totalEnergyStored <= 0) continue; float maxForPeace = ((ICustomArmor)stack.getItem()).getProtectionPoints(stack); - ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, (int)((summery.energyAllocation[i] / (double)summery.totalEnergyStored) * (totalPointsToAdd * 1000)), false); + int energyAmount = ((ICustomArmor)summery.armorStacks[i].getItem()).getEnergyPerProtectionPoint(); + ((IEnergyContainerItem)stack.getItem()).extractEnergy(stack, (int)((summery.energyAllocation[i] / (double)summery.totalEnergyStored) * (totalPointsToAdd * energyAmount)), false); float pointsForPeace = (summery.pointsDown[i] / Math.max(1, summery.maxProtectionPoints - summery.protectionPoints)) * totalPointsToAdd; summery.allocation[i] += pointsForPeace; if (summery.allocation[i] > maxForPeace || maxForPeace - summery.allocation[i] < 0.1F) summery.allocation[i] = maxForPeace; @@ -310,14 +313,14 @@ public class CustomArmorHandler { private static boolean applyArmorDamageBlocking(LivingAttackEvent event, ArmorSummery summery){ if (summery == null) return false; - if (event.source.isFireDamage() && summery.fireResistance >= 1) + if (event.source.isFireDamage() && summery.fireResistance >= 1F) { event.setCanceled(true); event.entityLiving.extinguish(); return true; } - if (event.source.damageType.equals("fall") && summery.jumpModifier > 0) + if (event.source.damageType.equals("fall") && summery.jumpModifier > 0F) { if (event.ammount < summery.jumpModifier * 5F) event.setCanceled(true); return true; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java index a71b1573..17c606b6 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/DraconicArmor.java @@ -1,5 +1,9 @@ package com.brandon3055.draconicevolution.common.items.armor; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + import com.brandon3055.brandonscore.BrandonsCore; import com.brandon3055.brandonscore.common.utills.InfoHelper; import com.brandon3055.brandonscore.common.utills.ItemNBTHelper; @@ -9,6 +13,7 @@ import com.brandon3055.draconicevolution.client.model.ModelDraconicArmor; import com.brandon3055.draconicevolution.client.model.ModelDraconicArmorOld; import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; +import com.brandon3055.draconicevolution.common.handler.BalanceConfigHandler; import com.brandon3055.draconicevolution.common.handler.ConfigHandler; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.ToolBase; import com.brandon3055.draconicevolution.common.lib.References; @@ -42,10 +47,6 @@ import net.minecraftforge.common.ISpecialArmor; import thaumcraft.api.IGoggles; import thaumcraft.api.nodes.IRevealer; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - /** * Created by Brandon on 3/07/2014. */ @@ -63,8 +64,8 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur @SideOnly(Side.CLIENT) private IIcon bootsIcon; - private int maxTransfer = References.DRACONICTRANSFER; - private int maxEnergy = References.DRACONICCAPACITY; + private int maxEnergy = BalanceConfigHandler.draconicArmorBaseStorage; + private int maxTransfer = BalanceConfigHandler.draconicArmorMaxTransfer; public DraconicArmor(ArmorMaterial material, int armorType, String name) { super(material, 0, armorType); @@ -115,6 +116,7 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur } @Override + @SideOnly(Side.CLIENT) public IIcon getIconIndex(ItemStack stack) { if (stack.getItem() == ModItems.draconicHelm) return helmIcon; else if (stack.getItem() == ModItems.draconicChest) return chestIcon; @@ -184,7 +186,10 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur if (stack == null) return; if (stack.getItem() == ModItems.draconicHelm) { if (world.isRemote) return; - if (this.getEnergyStored(stack) >= 5000 && clearNegativeEffects(player)) this.extractEnergy(stack, 5000, false); + if (this.getEnergyStored(stack) >= BalanceConfigHandler.draconicArmorEnergyToRemoveEffects && clearNegativeEffects(player)) + { + this.extractEnergy(stack, BalanceConfigHandler.draconicArmorEnergyToRemoveEffects, false); + } if (player.worldObj.getBlockLightValue((int)Math.floor(player.posX), (int) player.posY + 1, (int)Math.floor(player.posZ)) < 5 && IConfigurableItem.ProfileHelper.getBoolean(stack, "ArmorNVActive", false)) { player.addPotionEffect(new PotionEffect(Potion.nightVision.id, 419, 0, true)); @@ -214,8 +219,13 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur if (player.isBurning()) { player.extinguish(); - flag = true; - } else for (PotionEffect potion : potions) { + /* + * Wyvern Armor doesn't require energy to extinguish player => Draconic Armor shouldn't require. + * See CustomArmorHandler.applyArmorDamageBlocking + * */ + //flag = false; + } + for (PotionEffect potion : potions) { int id = potion.getPotionID(); if (ReflectionHelper.getPrivateValue(Potion.class, Potion.potionTypes[id], new String[]{"isBadEffect", "field_76418_K", "J"})) { if (potion.getPotionID() == Potion.digSlowdown.id && ModHelper.isHoldingCleaver(player)) break; @@ -248,7 +258,7 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { int stored = ItemNBTHelper.getInteger(container, "Energy", 0); - int extract = Math.min(maxExtract, stored); + int extract = Math.min(maxExtract, Math.min(maxTransfer, stored)); if (!simulate) { stored -= extract; @@ -264,8 +274,8 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur @Override public int getMaxEnergyStored(ItemStack container) { - int i = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); - return i * 5000000; + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); + return BalanceConfigHandler.draconicArmorBaseStorage + points * BalanceConfigHandler.draconicArmorStoragePerUpgrade; } /* Misc */ @@ -444,7 +454,7 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur @Override public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) return 2; + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) return 0; else if (upgradeIndex == EnumUpgrade.SHIELD_CAPACITY.index) return (int)(getProtectionShare() * 25) + (armorType == 2 ? 2 : 0); else if (upgradeIndex == EnumUpgrade.SHIELD_RECOVERY.index) return 5; return 0; @@ -511,6 +521,11 @@ public class DraconicArmor extends ItemArmor implements ISpecialArmor, IConfigur } else return IConfigurableItem.ProfileHelper.getFloat(stack, "VerticalAcceleration", 0F); } + @Override + public int getEnergyPerProtectionPoint() + { + return BalanceConfigHandler.draconicArmorEnergyPerProtectionPoint; + } //endregion diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/ICustomArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/ICustomArmor.java index 19f2b2b1..bddb46fd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/ICustomArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/ICustomArmor.java @@ -12,32 +12,35 @@ public interface ICustomArmor extends IEnergyContainerItem { /**Returns the max number of protection points this armor piece can provide * 1 protection point equals 1 half heart of protection. * */ - public float getProtectionPoints(ItemStack stack); + float getProtectionPoints(ItemStack stack); - /**Reruns the number of Upgrade points applied to shield recovery*/ - public int getRecoveryPoints(ItemStack stack); + /**Returns the number of Upgrade points applied to shield recovery*/ + int getRecoveryPoints(ItemStack stack); /**Returns the movement speed modifier for this armor*/ - public float getSpeedModifier(ItemStack stack, EntityPlayer player); + float getSpeedModifier(ItemStack stack, EntityPlayer player); /**Returns the jump height modifier for this armor*/ - public float getJumpModifier(ItemStack stack, EntityPlayer player); + float getJumpModifier(ItemStack stack, EntityPlayer player); /**Returns true if this armor has up-hill step enabled*/ - public boolean hasHillStep(ItemStack stack, EntityPlayer player); + boolean hasHillStep(ItemStack stack, EntityPlayer player); /**Returns the fire resistance modifier for this armor * This is the percentage of fire damage this armor should absorb * If the total resistance for all armor peaces the player is wearing is >= 1 the player will not be damaged by fire. * Should return a number between 0 and 1*/ - public float getFireResistance(ItemStack stack); + float getFireResistance(ItemStack stack); /**Returns {true, false} if this armor gives the player flight * Returns {true, true} if flight lock is also enables on this armor*/ - public boolean[] hasFlight(ItemStack stack); + boolean[] hasFlight(ItemStack stack); - public float getFlightSpeedModifier(ItemStack stack, EntityPlayer player); + float getFlightSpeedModifier(ItemStack stack, EntityPlayer player); /**Returns the vertical acceleration speed*/ - public float getFlightVModifier(ItemStack stack, EntityPlayer player); + float getFlightVModifier(ItemStack stack, EntityPlayer player); + + /**Returns amount of energy, required to restore protection point */ + int getEnergyPerProtectionPoint(); } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java index 0015ff20..35077557 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/items/armor/WyvernArmor.java @@ -1,5 +1,8 @@ package com.brandon3055.draconicevolution.common.items.armor; +import java.util.ArrayList; +import java.util.List; + import com.brandon3055.brandonscore.BrandonsCore; import com.brandon3055.brandonscore.common.utills.InfoHelper; import com.brandon3055.brandonscore.common.utills.ItemNBTHelper; @@ -9,10 +12,14 @@ import com.brandon3055.draconicevolution.client.model.ModelDraconicArmorOld; import com.brandon3055.draconicevolution.client.model.ModelWyvernArmor; import com.brandon3055.draconicevolution.common.ModItems; import com.brandon3055.draconicevolution.common.entity.EntityPersistentItem; +import com.brandon3055.draconicevolution.common.handler.BalanceConfigHandler; import com.brandon3055.draconicevolution.common.handler.ConfigHandler; import com.brandon3055.draconicevolution.common.items.tools.baseclasses.ToolBase; import com.brandon3055.draconicevolution.common.lib.References; -import com.brandon3055.draconicevolution.common.utills.*; +import com.brandon3055.draconicevolution.common.utills.IConfigurableItem; +import com.brandon3055.draconicevolution.common.utills.IInventoryTool; +import com.brandon3055.draconicevolution.common.utills.IUpgradableItem; +import com.brandon3055.draconicevolution.common.utills.ItemConfigField; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -31,20 +38,21 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; -import java.util.ArrayList; -import java.util.List; - /** * Created by Brandon on 3/07/2014. */ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IConfigurableItem, IInventoryTool, IUpgradableItem, ICustomArmor { + @SideOnly(Side.CLIENT) private IIcon helmIcon; + @SideOnly(Side.CLIENT) private IIcon chestIcon; + @SideOnly(Side.CLIENT) private IIcon leggsIcon; + @SideOnly(Side.CLIENT) private IIcon bootsIcon; - private int maxTransfer = References.WYVERNTRANSFER; - private int maxEnergy = References.WYVERNCAPACITY; + private int maxEnergy = BalanceConfigHandler.wyvernArmorBaseStorage; + private int maxTransfer = BalanceConfigHandler.wyvernArmorMaxTransfer; public WyvernArmor(ArmorMaterial material, int armorType, String name) { super(material, 0, armorType); @@ -95,6 +103,7 @@ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IConfigurab } @Override + @SideOnly(Side.CLIENT) public IIcon getIconIndex(ItemStack stack) { if (stack.getItem() == ModItems.wyvernHelm) return helmIcon; else if (stack.getItem() == ModItems.wyvernChest) return chestIcon; @@ -198,7 +207,7 @@ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IConfigurab public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { int stored = ItemNBTHelper.getInteger(container, "Energy", 0); - int extract = Math.min(maxExtract, stored); + int extract = Math.min(maxExtract, Math.min(maxTransfer, stored)); if (!simulate) { stored -= extract; @@ -214,8 +223,8 @@ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IConfigurab @Override public int getMaxEnergyStored(ItemStack container) { - int i = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); - return i * 500000; + int points = IUpgradableItem.EnumUpgrade.RF_CAPACITY.getUpgradePoints(container); + return BalanceConfigHandler.wyvernArmorBaseStorage + points * BalanceConfigHandler.wyvernArmorStoragePerUpgrade; } @Override @@ -355,7 +364,7 @@ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IConfigurab @Override public int getBaseUpgradePoints(int upgradeIndex) { - if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) return 2; + if (upgradeIndex == EnumUpgrade.RF_CAPACITY.index) return 0; else if (upgradeIndex == EnumUpgrade.SHIELD_CAPACITY.index) return (int)(getProtectionShare() * 10) + (armorType == 2 ? 1 : 0); else if (upgradeIndex == EnumUpgrade.SHIELD_RECOVERY.index) return 5; return 0; @@ -412,6 +421,11 @@ public class WyvernArmor extends ItemArmor implements ISpecialArmor, IConfigurab public float getFlightVModifier(ItemStack stack, EntityPlayer player) { return 0; } + @Override + public int getEnergyPerProtectionPoint() + { + return BalanceConfigHandler.wyvernArmorEnergyPerProtectionPoint; + } //endregion diff --git a/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java b/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java index c270b354..89774011 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/lib/References.java @@ -12,10 +12,6 @@ public final class References { //======================Tools & Weapons========================// - public static final int WYVERNCAPACITY = 1000000; - public static final int WYVERNTRANSFER = 50000; - public static final int DRACONICCAPACITY = 10000000; - public static final int DRACONICTRANSFER = 500000; public static final int MAX_WYVERN_UPGRADES = 3; public static final int MAX_DRACONIC_UPGRADES = 6;