From 4a58fc551839d004d03af1791defa0cf62d32d97 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Tue, 29 Mar 2016 09:22:25 -0400 Subject: [PATCH] Updated Forge to 1813. Worked on the SentientArmour so that it is able to use the different will types depending on what is the highest. --- .settings/org.eclipse.jdt.core.prefs | 6 +- gradle.properties | 2 +- .../item/armour/ItemSentientArmour.java | 156 ++++++++++++++---- .../item/soul/ItemSentientArmourGem.java | 29 +--- .../blockstates/item/ItemSentientArmour.json | 88 +++++++++- 5 files changed, 217 insertions(+), 64 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index ef19e8a2..601d3aaf 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,5 @@ # -#Sat Mar 26 21:55:12 EDT 2016 +#Tue Mar 29 09:15:42 EDT 2016 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert org.eclipse.jdt.core.formatter.brace_position_for_block=next_line org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert @@ -288,10 +288,10 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert -org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line eclipse.preferences.version=1 -org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=next_line org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 diff --git a/gradle.properties b/gradle.properties index 4a9c172e..3bdadc31 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ mod_name=BloodMagic package_group=com.wayoftime.bloodmagic mod_version=2.0.0 mc_version=1.9 -forge_version=12.16.0.1811-1.9 +forge_version=12.16.0.1813-1.9 curse_id=224791 mappings_version=snapshot_20160321 diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java index e97f0fec..17b34e5e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import WayofTime.bloodmagic.client.IMeshProvider; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.enchantment.Enchantment; @@ -19,19 +18,25 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.ISpecialArmor; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.iface.IMultiWillTool; import WayofTime.bloodmagic.api.soul.EnumDemonWillType; import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler; import WayofTime.bloodmagic.api.util.helper.NBTHelper; +import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.registry.ModItems; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; -public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider +public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider, IMultiWillTool { public static String[] names = { "helmet", "chest", "legs", "boots" }; + public static double[] willBracket = new double[] { 30, 200, 600, 1500, 4000, 6000, 8000, 16000 }; + public static double[] consumptionPerHit = new double[] { 0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5 }; + public static double[] extraProtectionLevel = new double[] { 0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9 }; + public ItemSentientArmour(EntityEquipmentSlot armorType) { super(ItemArmor.ArmorMaterial.IRON, 0, armorType); @@ -40,22 +45,43 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes setCreativeTab(BloodMagic.tabBloodMagic); } - public EnumDemonWillType getDemonWillTypeConsumed(ItemStack stack) - { - return EnumDemonWillType.DEFAULT; - } - @Override public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { if (this == ModItems.sentientArmourChest || this == ModItems.sentientArmourHelmet || this == ModItems.sentientArmourBoots) { + switch (this.getCurrentType(stack)) + { + case DEFAULT: + return "bloodmagic:models/armor/sentientArmour_layer_1.png"; + case CORROSIVE: + return "bloodmagic:models/armor/sentientArmour_corrosive_layer_1.png"; + case VENGEFUL: + return "bloodmagic:models/armor/sentientArmour_vengeful_layer_1.png"; + case DESTRUCTIVE: + return "bloodmagic:models/armor/sentientArmour_destructive_layer_1.png"; + case STEADFAST: + return "bloodmagic:models/armor/sentientArmour_steadfast_layer_1.png"; + } return "bloodmagic:models/armor/sentientArmour_layer_1.png"; } if (this == ModItems.sentientArmourLegs) { - return "bloodmagic:models/armor/sentientArmour_layer_2.png"; + switch (this.getCurrentType(stack)) + { + case DEFAULT: + return "bloodmagic:models/armor/sentientArmour_layer_2.png"; + case CORROSIVE: + return "bloodmagic:models/armor/sentientArmour_corrosive_layer_2.png"; + case VENGEFUL: + return "bloodmagic:models/armor/sentientArmour_vengeful_layer_2.png"; + case DESTRUCTIVE: + return "bloodmagic:models/armor/sentientArmour_destructive_layer_2.png"; + case STEADFAST: + return "bloodmagic:models/armor/sentientArmour_steadfast_layer_2.png"; + } + return "bloodmagic:models/armor/sentientArmour_layer_1.png"; } else { return null; @@ -169,12 +195,13 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes { EntityPlayer player = (EntityPlayer) entity; - EnumDemonWillType type = getDemonWillTypeConsumed(stack); + EnumDemonWillType type = getCurrentType(stack); double willRequired = this.getCostModifier(stack) * damage; double willLeft = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (willLeft >= willRequired) + if (willLeft >= willRequired && canSustainArmour(type, willLeft)) { + this.setAbilitiesOfArmour(type, willLeft - willRequired, stack); PlayerDemonWillHandler.consumeDemonWill(type, player, willRequired); } else { @@ -218,14 +245,13 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes @Override public String getUnlocalizedName(ItemStack stack) { - return super.getUnlocalizedName(stack) + names[armorType.getIndex()]; + return super.getUnlocalizedName(stack) + names[3 - armorType.getIndex()]; } public void revertArmour(EntityPlayer player, ItemStack itemStack) { ItemStack stack = this.getContainedArmourStack(itemStack); player.setItemStackToSlot(armorType, stack); -// player.inventory.armorInventory[3 - armorType.getIndex()] = stack; } @Override @@ -238,14 +264,16 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes public ModelResourceLocation getModelLocation(ItemStack stack) { assert getCustomLocation() != null; + EnumDemonWillType type = ((ItemSentientArmour) ModItems.sentientArmourHelmet).getCurrentType(stack); + String additional = "_" + type.getName().toLowerCase(); if (stack.getItem() == ModItems.sentientArmourHelmet) - return new ModelResourceLocation(getCustomLocation(), "armour=head"); + return new ModelResourceLocation(getCustomLocation(), "armour=head" + additional); else if (stack.getItem() == ModItems.sentientArmourChest) - return new ModelResourceLocation(getCustomLocation(), "armour=body"); + return new ModelResourceLocation(getCustomLocation(), "armour=body" + additional); else if (stack.getItem() == ModItems.sentientArmourLegs) - return new ModelResourceLocation(getCustomLocation(), "armour=leg"); + return new ModelResourceLocation(getCustomLocation(), "armour=leg" + additional); else - return new ModelResourceLocation(getCustomLocation(), "armour=feet"); + return new ModelResourceLocation(getCustomLocation(), "armour=feet" + additional); } }; } @@ -260,10 +288,16 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes public List getVariants() { List ret = new ArrayList(); - ret.add("armour=head"); - ret.add("armour=body"); - ret.add("armour=leg"); - ret.add("armour=feet"); + for (EnumDemonWillType type : EnumDemonWillType.values()) + { + String additional = "_" + type.getName().toLowerCase(); + + ret.add("armour=head" + additional); + ret.add("armour=body" + additional); + ret.add("armour=leg" + additional); + ret.add("armour=feet" + additional); + } + return ret; } @@ -315,18 +349,23 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes return armourStack; } - public static boolean convertPlayerArmour(EntityPlayer player, double recurringCost, double protection) + public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player) { + if (!canSustainArmour(type, will)) + { + return false; + } + ItemStack helmetStack = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST); ItemStack leggingsStack = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS); ItemStack bootsStack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); { - ItemStack omegaHelmetStack = ((ItemSentientArmour) ModItems.sentientArmourHelmet).getSubstituteStack(helmetStack, recurringCost, protection); - ItemStack omegaChestStack = ((ItemSentientArmour) ModItems.sentientArmourChest).getSubstituteStack(chestStack, recurringCost, protection); - ItemStack omegaLeggingsStack = ((ItemSentientArmour) ModItems.sentientArmourLegs).getSubstituteStack(leggingsStack, recurringCost, protection); - ItemStack omegaBootsStack = ((ItemSentientArmour) ModItems.sentientArmourBoots).getSubstituteStack(bootsStack, recurringCost, protection); + ItemStack omegaHelmetStack = ((ItemSentientArmour) ModItems.sentientArmourHelmet).getSubstituteStack(type, will, helmetStack); + ItemStack omegaChestStack = ((ItemSentientArmour) ModItems.sentientArmourChest).getSubstituteStack(type, will, chestStack); + ItemStack omegaLeggingsStack = ((ItemSentientArmour) ModItems.sentientArmourLegs).getSubstituteStack(type, will, leggingsStack); + ItemStack omegaBootsStack = ((ItemSentientArmour) ModItems.sentientArmourBoots).getSubstituteStack(type, will, bootsStack); player.setItemStackToSlot(EntityEquipmentSlot.HEAD, omegaHelmetStack); player.setItemStackToSlot(EntityEquipmentSlot.CHEST, omegaChestStack); @@ -337,14 +376,71 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } } - public ItemStack getSubstituteStack(ItemStack previousArmour, double recurringCost, double protection) + public ItemStack getSubstituteStack(EnumDemonWillType type, double will, ItemStack previousArmour) { ItemStack newArmour = new ItemStack(this); this.setContainedArmourStack(newArmour, previousArmour); - this.setCostModifier(newArmour, recurringCost); - this.setArmourModifier(newArmour, protection); + this.setAbilitiesOfArmour(type, will, newArmour); return newArmour; } + + @Override + public EnumDemonWillType getCurrentType(ItemStack stack) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) + { + return EnumDemonWillType.DEFAULT; + } + + return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE)); + } + + public void setCurrentType(EnumDemonWillType type, ItemStack stack) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setString(Constants.NBT.WILL_TYPE, type.toString()); + } + + public void setAbilitiesOfArmour(EnumDemonWillType type, double willValue, ItemStack armourStack) + { + int willBracket = getWillBracket(willValue); + if (willBracket >= 0) + { + double recurringCost = consumptionPerHit[willBracket]; + double protection = extraProtectionLevel[willBracket]; + + this.setCostModifier(armourStack, recurringCost); + this.setArmourModifier(armourStack, protection); + this.setCurrentType(type, armourStack); + } + } + + public static boolean canSustainArmour(EnumDemonWillType type, double willValue) + { + return getWillBracket(willValue) >= 0; + } + + public static int getWillBracket(double will) + { + int bracket = -1; + + for (int i = 0; i < willBracket.length; i++) + { + if (will >= willBracket[i]) + { + bracket = i; + } + } + + return bracket; + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java index aed2d29d..0c1a83be 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientArmourGem.java @@ -18,10 +18,6 @@ import WayofTime.bloodmagic.item.armour.ItemSentientArmour; public class ItemSentientArmourGem extends Item { - public static double[] willBracket = new double[] { 30, 200, 600, 1500, 4000, 6000, 8000, 16000 }; - public static double[] consumptionPerHit = new double[] { 0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5 }; - public static double[] extraProtectionLevel = new double[] { 0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9 }; - public ItemSentientArmourGem() { super(); @@ -55,35 +51,16 @@ public class ItemSentientArmourGem extends Item ItemSentientArmour.revertAllArmour(player); } else { - double will = PlayerDemonWillHandler.getTotalDemonWill(getCurrentType(stack), player); + EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); + double will = PlayerDemonWillHandler.getTotalDemonWill(type, player); - int bracket = getWillBracket(will); - - if (bracket >= 0) - { // PlayerDemonWillHandler.consumeDemonWill(player, willBracket[bracket]); - ItemSentientArmour.convertPlayerArmour(player, consumptionPerHit[bracket], extraProtectionLevel[bracket]); - } + ItemSentientArmour.convertPlayerArmour(type, will, player); } return new ActionResult(EnumActionResult.PASS, stack); } - public int getWillBracket(double will) - { - int bracket = -1; - - for (int i = 0; i < willBracket.length; i++) - { - if (will >= willBracket[i]) - { - bracket = i; - } - } - - return bracket; - } - @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) { diff --git a/src/main/resources/assets/bloodmagic/blockstates/item/ItemSentientArmour.json b/src/main/resources/assets/bloodmagic/blockstates/item/ItemSentientArmour.json index 270f670d..92324fbe 100644 --- a/src/main/resources/assets/bloodmagic/blockstates/item/ItemSentientArmour.json +++ b/src/main/resources/assets/bloodmagic/blockstates/item/ItemSentientArmour.json @@ -6,25 +6,105 @@ }, "variants": { "armour": { - "head": { + "head_default": { "textures": { "layer0": "bloodmagic:items/SentientHelmet" } }, - "body": { + "body_default": { "textures": { "layer0": "bloodmagic:items/SentientPlate" } }, - "leg": { + "leg_default": { "textures": { "layer0": "bloodmagic:items/SentientLeggings" } }, - "feet": { + "feet_default": { "textures": { "layer0": "bloodmagic:items/SentientBoots" } + }, + "head_corrosive": { + "textures": { + "layer0": "bloodmagic:items/SentientHelmet_corrosive" + } + }, + "body_corrosive": { + "textures": { + "layer0": "bloodmagic:items/SentientPlate_corrosive" + } + }, + "leg_corrosive": { + "textures": { + "layer0": "bloodmagic:items/SentientLeggings_corrosive" + } + }, + "feet_corrosive": { + "textures": { + "layer0": "bloodmagic:items/SentientBoots_corrosive" + } + }, + "head_vengeful": { + "textures": { + "layer0": "bloodmagic:items/SentientHelmet_vengeful" + } + }, + "body_vengeful": { + "textures": { + "layer0": "bloodmagic:items/SentientPlate_vengeful" + } + }, + "leg_vengeful": { + "textures": { + "layer0": "bloodmagic:items/SentientLeggings_vengeful" + } + }, + "feet_vengeful": { + "textures": { + "layer0": "bloodmagic:items/SentientBoots_vengeful" + } + }, + "head_destructive": { + "textures": { + "layer0": "bloodmagic:items/SentientHelmet_destructive" + } + }, + "body_destructive": { + "textures": { + "layer0": "bloodmagic:items/SentientPlate_destructive" + } + }, + "leg_destructive": { + "textures": { + "layer0": "bloodmagic:items/SentientLeggings_destructive" + } + }, + "feet_destructive": { + "textures": { + "layer0": "bloodmagic:items/SentientBoots_destructive" + } + }, + "head_steadfast": { + "textures": { + "layer0": "bloodmagic:items/SentientHelmet_steadfast" + } + }, + "body_steadfast": { + "textures": { + "layer0": "bloodmagic:items/SentientPlate_steadfast" + } + }, + "leg_steadfast": { + "textures": { + "layer0": "bloodmagic:items/SentientLeggings_steadfast" + } + }, + "feet_steadfast": { + "textures": { + "layer0": "bloodmagic:items/SentientBoots_steadfast" + } } } }