summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/util
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
parent05b5b13256c420568d1f07ed634dfd47509d53f2 (diff)
Lots of new things
Diffstat (limited to 'common/darkknight/jewelrycraft/util')
-rw-r--r--common/darkknight/jewelrycraft/util/JewelryNBT.java62
-rw-r--r--common/darkknight/jewelrycraft/util/JewelrycraftUtil.java12
2 files changed, 68 insertions, 6 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;
+ }
}
diff --git a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java
index b344724..4247175 100644
--- a/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java
+++ b/common/darkknight/jewelrycraft/util/JewelrycraftUtil.java
@@ -34,6 +34,12 @@ public class JewelrycraftUtil
modifiers.add(new ItemStack(Item.potion, 1, 8270));
//Jewels
+ for(int i=0; i <= 16; i++)
+ jewel.add(new ItemStack(ItemList.crystal, 1, i));
+ jewel.add(new ItemStack(Item.redstone));
+ jewel.add(new ItemStack(Block.blockRedstone));
+ jewel.add(new ItemStack(Item.dyePowder, 1, 4));
+ jewel.add(new ItemStack(Block.blockLapis));
jewel.add(new ItemStack(Block.obsidian));
jewel.add(new ItemStack(Item.diamond));
jewel.add(new ItemStack(Item.emerald));
@@ -83,15 +89,15 @@ public class JewelrycraftUtil
{
while(index2 < OreDictionary.getOres(OreDictionary.getOreNames()[index]).size())
{
- if(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2).getUnlocalizedName().contains("ingot"))
+ if(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2).getUnlocalizedName().toLowerCase().contains("ingot") && !JewelrycraftUtil.metal.contains(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2)))
metal.add(OreDictionary.getOres(OreDictionary.getOreNames()[index]).get(index2));
index2++;
}
index2 = 0;
index++;
}
- metal.add(new ItemStack(Item.ingotGold));
- metal.add(new ItemStack(Item.ingotIron));
+ if(!metal.contains(new ItemStack(Item.ingotGold)))metal.add(new ItemStack(Item.ingotGold));
+ if(!metal.contains(new ItemStack(Item.ingotIron)))metal.add(new ItemStack(Item.ingotIron));
}
public static boolean isModifier(ItemStack item)