Added some extra framework for Living Armour.
This commit is contained in:
parent
5273a85711
commit
f27ee1aeb4
|
@ -67,6 +67,8 @@ public class Constants
|
||||||
public static final String CONTAINED_BLOCK_META = "containedBlockMeta";
|
public static final String CONTAINED_BLOCK_META = "containedBlockMeta";
|
||||||
|
|
||||||
public static final String PREVIOUS_INPUT = "previousInput";
|
public static final String PREVIOUS_INPUT = "previousInput";
|
||||||
|
|
||||||
|
public static final String LIVING_ARMOUR = "livingArmour";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Mod
|
public static class Mod
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package WayofTime.bloodmagic.item.armour;
|
package WayofTime.bloodmagic.item.armour;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.BloodMagic;
|
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
|
||||||
import WayofTime.bloodmagic.registry.ModItems;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.item.ItemArmor;
|
import net.minecraft.item.ItemArmor;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import WayofTime.bloodmagic.BloodMagic;
|
||||||
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
|
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||||
|
import WayofTime.bloodmagic.registry.ModItems;
|
||||||
|
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
public class ItemLivingArmour extends ItemArmor
|
public class ItemLivingArmour extends ItemArmor
|
||||||
{
|
{
|
||||||
|
@ -36,9 +41,38 @@ public class ItemLivingArmour extends ItemArmor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Multimap<String, AttributeModifier> getAttributeModifiers(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (this == ModItems.livingArmourChest)
|
||||||
|
{
|
||||||
|
LivingArmour armour = getLivingArmour(stack);
|
||||||
|
|
||||||
|
return armour.getAttributeModifiers();
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getAttributeModifiers(stack);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUnlocalizedName(ItemStack stack)
|
public String getUnlocalizedName(ItemStack stack)
|
||||||
{
|
{
|
||||||
return super.getUnlocalizedName(stack) + names[armorType];
|
return super.getUnlocalizedName(stack) + names[armorType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LivingArmour getLivingArmour(ItemStack stack)
|
||||||
|
{
|
||||||
|
if (!stack.hasTagCompound())
|
||||||
|
{
|
||||||
|
stack.setTagCompound(new NBTTagCompound());
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
NBTTagCompound livingTag = tag.getCompoundTag(Constants.NBT.LIVING_ARMOUR);
|
||||||
|
|
||||||
|
LivingArmour livingArmour = new LivingArmour();
|
||||||
|
livingArmour.readFromNBT(livingTag);
|
||||||
|
|
||||||
|
return livingArmour;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.lang.reflect.Constructor;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
@ -12,10 +13,26 @@ import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
|
||||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||||
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashMultimap;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
public class LivingArmour
|
public class LivingArmour
|
||||||
{
|
{
|
||||||
public HashMap<String, StatTracker> trackerMap = new HashMap();
|
public HashMap<String, StatTracker> trackerMap = new HashMap<String, StatTracker>();
|
||||||
public HashMap<String, LivingArmourUpgrade> upgradeMap = new HashMap();
|
public HashMap<String, LivingArmourUpgrade> upgradeMap = new HashMap<String, LivingArmourUpgrade>();
|
||||||
|
|
||||||
|
public Multimap<String, AttributeModifier> getAttributeModifiers()
|
||||||
|
{
|
||||||
|
HashMultimap<String, AttributeModifier> modifierMap = HashMultimap.<String, AttributeModifier>create();
|
||||||
|
|
||||||
|
for (Entry<String, LivingArmourUpgrade> entry : upgradeMap.entrySet())
|
||||||
|
{
|
||||||
|
LivingArmourUpgrade upgrade = entry.getValue();
|
||||||
|
modifierMap.putAll(upgrade.getAttributeModifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifierMap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ticks the upgrades and stat trackers, passing in the world and player as
|
* Ticks the upgrades and stat trackers, passing in the world and player as
|
||||||
|
|
Loading…
Reference in a new issue