summaryrefslogtreecommitdiff
path: root/common/darkknight/jewelrycraft/util/JewelryNBT.java
diff options
context:
space:
mode:
authorOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-24 21:01:41 +0200
committerOnyxDarkKnight <sor1n.iliutza16@gmail.com>2013-12-24 21:01:41 +0200
commit1997f4547812121223836dcacfcb31ea63acdda6 (patch)
treec6962617e7c2374b9d7393846d94bc99c21f940c /common/darkknight/jewelrycraft/util/JewelryNBT.java
parent198677e5b01009a65d243da1d25a14f879df659c (diff)
Fixed some bugs with tile entities, fixed rings rendering issue, added interdimensional teleporting rings and ender chest ring
Diffstat (limited to 'common/darkknight/jewelrycraft/util/JewelryNBT.java')
-rw-r--r--common/darkknight/jewelrycraft/util/JewelryNBT.java83
1 files changed, 83 insertions, 0 deletions
diff --git a/common/darkknight/jewelrycraft/util/JewelryNBT.java b/common/darkknight/jewelrycraft/util/JewelryNBT.java
index b6140b7..c097a49 100644
--- a/common/darkknight/jewelrycraft/util/JewelryNBT.java
+++ b/common/darkknight/jewelrycraft/util/JewelryNBT.java
@@ -1,7 +1,10 @@
package darkknight.jewelrycraft.util;
+import net.minecraft.entity.EntityList;
+import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
public class JewelryNBT
{
@@ -51,6 +54,37 @@ public class JewelryNBT
itemStackData.setTag("modifier", modifierNBT);
}
+ public static void addEntity(ItemStack item, EntityLivingBase entity)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound entityNBT = new NBTTagCompound();
+ entity.writeToNBT(entityNBT);
+ itemStackData.setTag("entity", entityNBT);
+ }
+
+ public static void addEntityID(ItemStack item, EntityLivingBase entity)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound entityNBT = new NBTTagCompound();
+ int id = EntityList.getEntityID(entity);
+ entityNBT.setInteger("entityID", id);
+ itemStackData.setTag("entityID", entityNBT);
+ }
+
public static void addCoordonates(ItemStack item, double x, double y, double z)
{
NBTTagCompound itemStackData;
@@ -70,4 +104,53 @@ public class JewelryNBT
itemStackData.setTag("z", coords);
}
+ public static void addCoordonatesAndDimension(ItemStack item, double x, double y, double z, int dim, String name)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ NBTTagCompound coords = new NBTTagCompound();
+ coords.setDouble("x", x);
+ coords.setDouble("y", y);
+ coords.setDouble("z", z);
+ coords.setInteger("dimension", dim);
+ coords.setString("dimName", name);
+ itemStackData.setTag("x", coords);
+ itemStackData.setTag("y", coords);
+ itemStackData.setTag("z", coords);
+ itemStackData.setTag("dimension", coords);
+ itemStackData.setTag("dimName", coords);
+ }
+
+ public static void removeNBT(ItemStack item, String tag)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ itemStackData.removeTag(tag);
+ }
+
+ public static void addEnchantment(ItemStack item)
+ {
+ NBTTagCompound itemStackData;
+ if (item.hasTagCompound())
+ itemStackData = item.getTagCompound();
+ else
+ {
+ itemStackData = new NBTTagCompound();
+ item.setTagCompound(itemStackData);
+ }
+ itemStackData.setTag("ench", new NBTTagList("ench"));
+ }
+
}