Fixed horrible memory leak in the Living Armour. Fixes #825

This commit is contained in:
WayofTime 2016-06-26 09:38:13 -04:00
parent afa6ccd7f3
commit c69b6bbade
12 changed files with 152 additions and 99 deletions

View file

@ -1,3 +1,8 @@
------------------------------------------------------
Version 2.0.2-47
------------------------------------------------------
- Fixed horrible memory leak in the Living Armour.
------------------------------------------------------
Version 2.0.2-46
------------------------------------------------------

View file

@ -1,14 +1,9 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.util.helper.TextHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
@ -19,12 +14,19 @@ import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.util.helper.TextHelper;
public class ItemUpgradeTome extends Item implements IVariantProvider
{
@ -55,7 +57,7 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour)
{
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
if (armour == null)
{
return super.onItemRightClick(stack, world, player, hand);
@ -63,7 +65,7 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
if (armour.upgradeArmour(player, upgrade))
{
ItemLivingArmour.armourMap.put(chestStack, armour);
ItemLivingArmour.setLivingArmour(chestStack, armour);
// ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(stack, armour, false);
stack.stackSize--;
}

View file

@ -7,16 +7,12 @@ import java.util.List;
import lombok.Getter;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.potion.PotionUtils;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
@ -27,8 +23,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.collect.Iterables;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
@ -38,6 +32,8 @@ import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.collect.Iterables;
public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvider
{
@Getter
@ -84,14 +80,14 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
if (armour.maxUpgradePoints < 200)
{
armour.maxUpgradePoints = 200;
((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
ItemLivingArmour.armourMap.put(chestStack, armour);
ItemLivingArmour.setLivingArmour(chestStack, armour);
}
}
}

View file

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.ItemMeshDefinition;
@ -39,6 +40,7 @@ import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra;
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
import WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor;
import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.util.Utils;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.collect.HashMultimap;
@ -54,7 +56,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
public static final boolean useSpecialArmourCalculation = true;
//TODO: Save/delete cache periodically.
public static Map<ItemStack, LivingArmour> armourMap = new HashMap<ItemStack, LivingArmour>();
public static Map<UUID, LivingArmour> armourMap = new HashMap<UUID, LivingArmour>();
public ItemLivingArmour(EntityEquipmentSlot armorType)
{
@ -150,9 +152,9 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
{
double remainder = 1; // Multiply this number by the armour upgrades for protection
if (armourMap.containsKey(stack))
if (hasLivingArmour(stack))
{
LivingArmour armour = armourMap.get(stack);
LivingArmour armour = getLivingArmour(stack);
if (armour != null && isEnabled(stack))
{
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
@ -252,7 +254,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
if (this == ModItems.livingArmourChest)
{
LivingArmour armour = getLivingArmour(stack);
LivingArmour armour = getLivingArmourFromStack(stack);
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
{
LivingArmourUpgrade upgrade = entry.getValue();
@ -333,12 +335,12 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
if (this == ModItems.livingArmourChest)
{
if (!armourMap.containsKey(stack))
if (!hasLivingArmour(stack))
{
armourMap.put(stack, getLivingArmour(stack));
setLivingArmour(stack, getLivingArmourFromStack(stack));
}
LivingArmour armour = armourMap.get(stack);
LivingArmour armour = getLivingArmour(stack);
if (LivingArmour.hasFullSet(player))
{
this.setIsEnabled(stack, true);
@ -354,7 +356,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
{
if (this == ModItems.livingArmourChest && isEnabled(stack) && slot == EntityEquipmentSlot.CHEST)
{
LivingArmour armour = ItemLivingArmour.getLivingArmour(stack);
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(stack);
return armour.getAttributeModifiers();
}
@ -407,7 +409,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
return ret;
}
public static LivingArmour getLivingArmour(ItemStack stack)
public static LivingArmour getLivingArmourFromStack(ItemStack stack)
{
NBTTagCompound livingTag = getArmourTag(stack);
@ -459,12 +461,12 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
//TODO: Add the ability to have the armour give an upgrade with a higher level
public static LivingArmourUpgrade getUpgrade(String uniqueIdentifier, ItemStack stack)
{
if (!armourMap.containsKey(stack))
if (!hasLivingArmour(stack))
{
armourMap.put(stack, getLivingArmour(stack));
setLivingArmour(stack, getLivingArmourFromStack(stack));
}
LivingArmour armour = armourMap.get(stack);
LivingArmour armour = getLivingArmour(stack);
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
{
@ -477,12 +479,39 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
return null;
}
public static boolean hasLivingArmour(ItemStack stack)
{
UUID uuid = Utils.getUUID(stack);
return uuid != null && armourMap.containsKey(uuid);
}
public static LivingArmour getLivingArmour(ItemStack stack)
{
UUID uuid = Utils.getUUID(stack);
return armourMap.get(uuid);
}
public static void setLivingArmour(ItemStack stack, LivingArmour armour)
{
if (!Utils.hasUUID(stack))
{
Utils.setUUID(stack);
}
UUID uuid = Utils.getUUID(stack);
armourMap.put(uuid, armour);
}
public static boolean hasUpgrade(String id, ItemStack stack)
{
if (!armourMap.containsKey(stack))
armourMap.put(stack, getLivingArmour(stack));
if (!hasLivingArmour(stack))
{
setLivingArmour(stack, getLivingArmourFromStack(stack));
}
LivingArmour armour = armourMap.get(stack);
LivingArmour armour = getLivingArmour(stack);
return armour.upgradeMap.containsKey(id);
}

View file

@ -1,14 +1,14 @@
package WayofTime.bloodmagic.item.inventory;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
import java.util.UUID;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import java.util.UUID;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
import WayofTime.bloodmagic.util.Utils;
public class InventoryHolding extends ItemInventory
{
@ -33,14 +33,14 @@ public class InventoryHolding extends ItemInventory
public ItemStack findParentStack(EntityPlayer entityPlayer)
{
if (hasUUID(masterStack))
if (Utils.hasUUID(masterStack))
{
UUID parentStackUUID = new UUID(masterStack.getTagCompound().getLong(Constants.NBT.MOST_SIG), masterStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG));
for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++)
{
ItemStack itemStack = entityPlayer.inventory.getStackInSlot(i);
if (itemStack != null && hasUUID(itemStack))
if (itemStack != null && Utils.hasUUID(itemStack))
{
if (itemStack.getTagCompound().getLong(Constants.NBT.MOST_SIG) == parentStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG) == parentStackUUID.getLeastSignificantBits())
{
@ -81,21 +81,4 @@ public class InventoryHolding extends ItemInventory
{
return 1;
}
public static boolean hasUUID(ItemStack itemStack)
{
return itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(Constants.NBT.MOST_SIG) && itemStack.getTagCompound().hasKey(Constants.NBT.LEAST_SIG);
}
public static void setUUID(ItemStack itemStack)
{
itemStack = NBTHelper.checkNBT(itemStack);
if (!itemStack.getTagCompound().hasKey(Constants.NBT.MOST_SIG) && !itemStack.getTagCompound().hasKey(Constants.NBT.LEAST_SIG))
{
UUID itemUUID = UUID.randomUUID();
itemStack.getTagCompound().setLong(Constants.NBT.MOST_SIG, itemUUID.getMostSignificantBits());
itemStack.getTagCompound().setLong(Constants.NBT.LEAST_SIG, itemUUID.getLeastSignificantBits());
}
}
}

View file

@ -1,15 +1,8 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.item.inventory.InventoryHolding;
import WayofTime.bloodmagic.util.handler.BMKeyBinding;
import WayofTime.bloodmagic.util.handler.IKeybindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -24,10 +17,20 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.commons.lang3.tuple.Pair;
import java.util.Collections;
import java.util.List;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.util.Utils;
import WayofTime.bloodmagic.util.handler.BMKeyBinding;
import WayofTime.bloodmagic.util.handler.IKeybindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings;
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader
{
@ -45,7 +48,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
{
if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(BMKeyBinding.Key.OPEN_SIGIL_HOLDING))
{
InventoryHolding.setUUID(stack);
Utils.setUUID(stack);
player.openGui(BloodMagic.instance, Constants.Gui.SIGIL_HOLDING_GUI, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
}
}

View file

@ -45,7 +45,7 @@ public class RitualArmourEvolve extends Ritual
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
if (armour.maxUpgradePoints < 300)

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.ItemStackWrapper;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
import WayofTime.bloodmagic.api.ritual.*;
@ -8,7 +9,9 @@ import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.registry.ModItems;
import com.google.common.collect.Iterables;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@ -54,7 +57,7 @@ public class RitualUpgradeRemove extends Ritual
boolean removedUpgrade = false;
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
@SuppressWarnings("unchecked")
@ -92,7 +95,7 @@ public class RitualUpgradeRemove extends Ritual
if (removedUpgrade)
{
((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
ItemLivingArmour.armourMap.put(chestStack, armour);
ItemLivingArmour.setLivingArmour(chestStack, armour);
masterRitualStone.setActive(false);

View file

@ -3,9 +3,10 @@ package WayofTime.bloodmagic.util;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.state.IBlockState;
@ -37,22 +38,22 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.discovery.ASMDataTable;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.SidedInvWrapper;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
import WayofTime.bloodmagic.network.PlayerVelocityPacketProcessor;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.tile.TileInventory;
import com.google.common.collect.Iterables;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.SidedInvWrapper;
import javax.annotation.Nullable;
public class Utils
{
@ -944,4 +945,31 @@ public class Utils
}
}
}
public static boolean hasUUID(ItemStack stack)
{
return stack.hasTagCompound() && stack.getTagCompound().hasKey(Constants.NBT.MOST_SIG) && stack.getTagCompound().hasKey(Constants.NBT.LEAST_SIG);
}
public static UUID getUUID(ItemStack stack)
{
if (!hasUUID(stack))
{
return null;
}
return new UUID(stack.getTagCompound().getLong(Constants.NBT.MOST_SIG), stack.getTagCompound().getLong(Constants.NBT.LEAST_SIG));
}
public static void setUUID(ItemStack stack)
{
stack = NBTHelper.checkNBT(stack);
if (!stack.getTagCompound().hasKey(Constants.NBT.MOST_SIG) && !stack.getTagCompound().hasKey(Constants.NBT.LEAST_SIG))
{
UUID itemUUID = UUID.randomUUID();
stack.getTagCompound().setLong(Constants.NBT.MOST_SIG, itemUUID.getMostSignificantBits());
stack.getTagCompound().setLong(Constants.NBT.LEAST_SIG, itemUUID.getLeastSignificantBits());
}
}
}

View file

@ -1,6 +1,5 @@
package WayofTime.bloodmagic.util.handler.event;
import WayofTime.bloodmagic.annot.Handler;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.EnchantmentHelper;
@ -24,6 +23,7 @@ import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.annot.Handler;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.event.ItemBindEvent;
@ -31,9 +31,13 @@ import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
import WayofTime.bloodmagic.api.event.TeleposeEvent;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.saving.SoulNetwork;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
import WayofTime.bloodmagic.api.util.helper.*;
import WayofTime.bloodmagic.api.saving.SoulNetwork;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.ItemHelper;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.block.BlockAltar;
import WayofTime.bloodmagic.item.ItemAltarMaker;
import WayofTime.bloodmagic.item.ItemExperienceBook;
@ -166,7 +170,7 @@ public class GenericHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
StatTrackerSelfSacrifice.incrementCounter(armour, event.healthDrained / 2);

View file

@ -41,7 +41,7 @@ public class LivingArmourHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
StatTrackerGrimReaperSprint.incrementCounter(armour);
@ -72,7 +72,7 @@ public class LivingArmourHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
StatTrackerJump.incrementCounter(armour);
@ -107,7 +107,7 @@ public class LivingArmourHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
if (armour != null)
{
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.stepAssist", chestStack);
@ -129,7 +129,7 @@ public class LivingArmourHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
if (armour != null)
{
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.movement", chestStack);
@ -171,7 +171,7 @@ public class LivingArmourHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
StatTrackerArrowShot.incrementCounter(armour);

View file

@ -45,7 +45,7 @@ public class StatTrackerHandler
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour)
{
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
@ -72,7 +72,7 @@ public class StatTrackerHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
StatTrackerHealthboost.incrementCounter(armour, event.getAmount());
@ -107,7 +107,7 @@ public class StatTrackerHandler
{
float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.getSource(), event.getAmount()), attackedPlayer.getHealth());
ItemStack chestStack = attackedPlayer.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
if (sourceEntity != null && !source.isMagicDamage() && !source.isProjectile())
@ -138,7 +138,7 @@ public class StatTrackerHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
ItemStack mainWeapon = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
@ -179,7 +179,7 @@ public class StatTrackerHandler
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.experienced", chestStack);