Improved the API and internal workings

Update things

Fix some more things

Update once more

Refactoring and removing unnecessary null checks

Woops

Fix

Nother fix

Moar fix

Fix imports

Update ItemBindable.java
This commit is contained in:
Arcaratus 2016-04-11 19:57:23 -04:00
parent 0a2dfb4fd4
commit 3e50dd4117
28 changed files with 389 additions and 340 deletions

View file

@ -4,7 +4,7 @@ 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.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades;
import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
@ -14,13 +14,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
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;
@ -47,7 +45,8 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
{
return super.onItemRightClick(stack, world, player, hand);
}
LivingArmourUpgrade upgrade = ItemUpgradeTome.getUpgrade(stack);
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
if (upgrade == null)
{
return super.onItemRightClick(stack, world, player, hand);
@ -83,8 +82,8 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
for (int i = 0; i < maxLevel; i++)
{
ItemStack stack = new ItemStack(this);
setKey(stack, key);
setLevel(stack, i);
LivingUpgrades.setKey(stack, key);
LivingUpgrades.setLevel(stack, i);
list.add(stack);
}
}
@ -98,52 +97,12 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
return ret;
}
public static LivingArmourUpgrade getUpgrade(ItemStack stack)
{
String key = getKey(stack);
int level = getLevel(stack);
return LivingArmourHandler.generateUpgradeFromKey(key, level);
}
public static void setKey(ItemStack stack, String key)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
tag.setString("key", key);
}
public static String getKey(ItemStack stack)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
return tag.getString("key");
}
public static void setLevel(ItemStack stack, int level)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
tag.setInteger("level", level);
}
public static int getLevel(ItemStack stack)
{
NBTHelper.checkNBT(stack);
NBTTagCompound tag = stack.getTagCompound();
return tag.getInteger("level");
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
{
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour"))));
LivingArmourUpgrade upgrade = ItemUpgradeTome.getUpgrade(stack);
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
if (upgrade != null)
{
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1));