summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/util/JewelryNBT.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-03-08 22:16:06 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2014-03-08 22:16:06 +0200
commit3e0556ee7aadfbb7695f87063662a9ca0d28175f (patch)
tree3a5ab57ce1e64e002fc22e16e91ae62a573d5f45 /common/darkknight/jewelrycraft/util/JewelryNBT.java
parent05b5b13256c420568d1f07ed634dfd47509d53f2 (diff)
Lots of new things
Diffstat (limited to 'common/darkknight/jewelrycraft/util/JewelryNBT.java')
-rw-r--r--common/darkknight/jewelrycraft/util/JewelryNBT.java62
1 files changed, 59 insertions, 3 deletions
diff --git a/common/darkknight/jewelrycraft/util/JewelryNBT.java b/common/darkknight/jewelrycraft/util/JewelryNBT.java
index 606ea4a..263b6b6 100644
--- a/common/darkknight/jewelrycraft/util/JewelryNBT.java
+++ b/common/darkknight/jewelrycraft/util/JewelryNBT.java
@@ -287,15 +287,19 @@ public class JewelryNBT
int entityID = 0;
entityID = enID.getInteger("entityID");
EntityLivingBase entity = (EntityLivingBase) EntityList.createEntityByID(entityID, player.worldObj);
- entity.readFromNBT(en);
- return entity;
+ if(entity != null && entity instanceof EntityLivingBase)
+ {
+ entity.readFromNBT(en);
+ return entity;
+ }
+ else return null;
}
return null;
}
public static boolean isEntityX(ItemStack stack, EntityPlayer player, EntityLivingBase entity)
{
- if(entity(stack, player) != null && entity(stack, player).equals(entity)) return true;
+ if(entity != null && entity instanceof EntityLivingBase && entity(stack, player) != null && entity(stack, player).equals(entity)) return true;
return false;
}
@@ -409,4 +413,56 @@ public class JewelryNBT
}
return -1;
}
+
+ public static void addIngotColor(ItemStack item, int color)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound colors = new NBTTagCompound();
+ colors.setInteger("ingotColor", color);
+ itemStackData.setTag("ingotColor", colors);
+ }
+
+ public static int ingotColor(ItemStack stack)
+ {
+ if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("ingotColor"))
+ {
+ NBTTagCompound colors = (NBTTagCompound) stack.getTagCompound().getTag("ingotColor");
+ int color = colors.getInteger("ingotColor");
+ return color;
+ }
+ return 16777215;
+ }
+
+ public static void addJewelColor(ItemStack item, int color)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound colors = new NBTTagCompound();
+ colors.setInteger("jewelColor", color);
+ itemStackData.setTag("jewelColor", colors);
+ }
+
+ public static int jewelColor(ItemStack stack)
+ {
+ if(stack != null && stack != new ItemStack(0, 0, 0) && stack.hasTagCompound() && stack.getTagCompound().hasKey("jewelColor"))
+ {
+ NBTTagCompound colors = (NBTTagCompound) stack.getTagCompound().getTag("jewelColor");
+ int color = colors.getInteger("jewelColor");
+ return color;
+ }
+ return 16777215;
+ }
}