diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-09-17 19:10:05 +0300 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2014-09-17 19:10:05 +0300 |
| commit | 06f62473f0622efe6decc32b70516a7c5d3d3572 (patch) | |
| tree | ebf54c96117f9917cd93740a89763c26abde06af /java/darkknight/jewelrycraft/util/PlayerUtils.java | |
| parent | 852cfd0e13631320624d528213ec8c80cffe8743 (diff) | |
1.7.10
Diffstat (limited to 'java/darkknight/jewelrycraft/util/PlayerUtils.java')
| -rw-r--r-- | java/darkknight/jewelrycraft/util/PlayerUtils.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/java/darkknight/jewelrycraft/util/PlayerUtils.java b/java/darkknight/jewelrycraft/util/PlayerUtils.java new file mode 100644 index 0000000..1135860 --- /dev/null +++ b/java/darkknight/jewelrycraft/util/PlayerUtils.java @@ -0,0 +1,43 @@ +package darkknight.jewelrycraft.util; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.integrated.IntegratedServer; +import cpw.mods.fml.common.FMLCommonHandler; + +/** + * Code taken from OpenBlocks + */ +public class PlayerUtils +{ + public static NBTTagCompound getModPlayerPersistTag(EntityPlayer player, String modName) + { + + NBTTagCompound tag = player.getEntityData(); + + NBTTagCompound persistTag = null; + if (tag.hasKey(EntityPlayer.PERSISTED_NBT_TAG)) + { + persistTag = tag.getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG); + } + else + { + persistTag = new NBTTagCompound(); + tag.setTag(EntityPlayer.PERSISTED_NBT_TAG, persistTag); + } + + NBTTagCompound modTag = null; + if (persistTag.hasKey(modName)) + { + modTag = persistTag.getCompoundTag(modName); + } + else + { + modTag = new NBTTagCompound(); + persistTag.setTag(modName, modTag); + } + + return modTag; + } +}
\ No newline at end of file |
