diff --git a/changelog.txt b/changelog.txt index 13968e9d..a27029f5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,8 @@ Version 2.0.0-27 - Fixed item binding. Yusssss. - Added Sword, Armour, and Bow texture changes when you have different demonic will in your inventory. - Finalized sentient sword effects +- Did work on the unique demon will effects for armour +- FINALLY changed it so farm animals do not drop demon will. ------------------------------------------------------ Version 2.0.0-23 diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java index 17b34e5e..ed05275e 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemSentientArmour.java @@ -3,6 +3,10 @@ package WayofTime.bloodmagic.item.armour; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.UUID; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -10,13 +14,17 @@ import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -37,6 +45,8 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes 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 static double[] healthBonus = new double[] { 3, 6, 9, 12, 15, 20, 25 }; + public ItemSentientArmour(EntityEquipmentSlot armorType) { super(ItemArmor.ArmorMaterial.IRON, 0, armorType); @@ -88,6 +98,51 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes } } + @Override + public void onArmorTick(World world, EntityPlayer player, ItemStack stack) + { + if (this.armorType == EntityEquipmentSlot.CHEST) + { + EnumDemonWillType type = this.getCurrentType(stack); + switch (type) + { + case CORROSIVE: + if (player.isPotionActive(MobEffects.poison)) + { + player.removeActivePotionEffect(MobEffects.poison); + } + if (player.isPotionActive(MobEffects.wither)) + { + player.removeActivePotionEffect(MobEffects.wither); + } + break; + default: + } + } + } + + public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer) + { + if (source.getEntity() instanceof EntityLivingBase) + { + EntityLivingBase attacker = (EntityLivingBase) source.getEntity(); + EnumDemonWillType type = this.getCurrentType(stack); + switch (type) + { + case CORROSIVE: + break; + case DEFAULT: + break; + case DESTRUCTIVE: + break; + case STEADFAST: + break; + case VENGEFUL: + break; + } + } + } + @Override public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) { @@ -301,6 +356,17 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes return ret; } + @Override + public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) + { + Multimap multimap = HashMultimap.create(); + if (slot == EntityEquipmentSlot.CHEST) + { + multimap.put(SharedMonsterAttributes.MAX_HEALTH.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(0, 318145), "Armor modifier", this.getHealthBonus(stack), 0)); + } + return multimap; + } + public static void revertAllArmour(EntityPlayer player) { ItemStack[] armourInventory = player.inventory.armorInventory; @@ -416,11 +482,36 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes if (willBracket >= 0) { double recurringCost = consumptionPerHit[willBracket]; - double protection = extraProtectionLevel[willBracket]; this.setCostModifier(armourStack, recurringCost); - this.setArmourModifier(armourStack, protection); this.setCurrentType(type, armourStack); + + if (this.armorType == EntityEquipmentSlot.CHEST) + { + this.setArmourModifier(armourStack, getArmourModifier(type, willBracket)); + this.setHealthBonus(armourStack, this.getHealthModifier(type, willBracket)); + } + } + } + + public double getArmourModifier(EnumDemonWillType type, int willBracket) + { + switch (type) + { + case STEADFAST: + default: + return extraProtectionLevel[willBracket]; + } + } + + public double getHealthModifier(EnumDemonWillType type, int willBracket) + { + switch (type) + { + case STEADFAST: + return healthBonus[willBracket]; + default: + return 0; } } @@ -443,4 +534,21 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes return bracket; } + + public double getHealthBonus(ItemStack stack) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH); + } + + public void setHealthBonus(ItemStack stack, double hp) + { + NBTHelper.checkNBT(stack); + + NBTTagCompound tag = stack.getTagCompound(); + + tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp); + } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java index 758616ca..93646f68 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java @@ -317,7 +317,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM { if (i == 0 || attackingEntity.worldObj.rand.nextDouble() < 0.4) { - ItemStack soulStack = soul.createWill(0, this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)); + ItemStack soulStack = soul.createWill(0, (this.getDropOfActivatedSword(stack) * attackingEntity.worldObj.rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d); soulList.add(soulStack); } } diff --git a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java index 761aba29..28401a88 100644 --- a/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java +++ b/src/main/java/WayofTime/bloodmagic/util/handler/EventHandler.java @@ -12,6 +12,7 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; @@ -79,6 +80,7 @@ import WayofTime.bloodmagic.item.ItemAltarMaker; import WayofTime.bloodmagic.item.ItemInscriptionTool; import WayofTime.bloodmagic.item.ItemUpgradeTome; import WayofTime.bloodmagic.item.armour.ItemLivingArmour; +import WayofTime.bloodmagic.item.armour.ItemSentientArmour; import WayofTime.bloodmagic.item.gear.ItemPackSacrifice; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot; @@ -578,6 +580,14 @@ public class EventHandler StatTrackerPhysicalProtect.incrementCounter(armour, amount); } } + } else + { + ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST); + if (chestStack != null && chestStack.getItem() instanceof ItemSentientArmour) + { + ItemSentientArmour armour = (ItemSentientArmour) chestStack.getItem(); + armour.onPlayerAttacked(chestStack, source, attackedPlayer); + } } } @@ -694,7 +704,7 @@ public class EventHandler DamageSource source = event.getSource(); Entity entity = source.getEntity(); - if (attackedEntity.isPotionActive(ModPotions.soulSnare)) + if (attackedEntity.isPotionActive(ModPotions.soulSnare) && attackedEntity instanceof EntityMob) { PotionEffect eff = attackedEntity.getActivePotionEffect(ModPotions.soulSnare); int lvl = eff.getAmplifier();