/// Initializes the entity's stats. @Override public void init(MobStatsInfo mobStats) { NBTTagCompound tag = new NBTTagCompound(); mobStats.theEntity.writeToNBT(tag); NBTTagList tagList = tag.getTagList("Pos", Constants.NBT.TAG_DOUBLE); double x = tagList.func_150309_d(0); double y = tagList.func_150309_d(1); double z = tagList.func_150309_d(2); tagList.func_150304_a(0, new NBTTagDouble(0.0)); tagList.func_150304_a(1, new NBTTagDouble(0.0)); tagList.func_150304_a(2, new NBTTagDouble(0.0)); tagList = tag.getTagList("Rotation", Constants.NBT.TAG_FLOAT); float yaw = tagList.func_150308_e(0); tagList.func_150304_a(0, new NBTTagFloat(0.0F)); this.nbtStats.generate(mobStats.theEntity, tag, mobStats); tagList = tag.getTagList("Pos", Constants.NBT.TAG_DOUBLE); tagList.func_150304_a(0, new NBTTagDouble(tagList.func_150309_d(0) + x)); tagList.func_150304_a(1, new NBTTagDouble(tagList.func_150309_d(1) + y)); tagList.func_150304_a(2, new NBTTagDouble(tagList.func_150309_d(2) + z)); tagList = tag.getTagList("Rotation", Constants.NBT.TAG_FLOAT); tagList.func_150304_a(0, new NBTTagFloat(tagList.func_150308_e(0) + yaw)); mobStats.theEntity.readFromNBT(tag); }
public static DataArray create(final NBTTagList nbt) { final DataArray list = new DataArray(); final int count = nbt.tagCount(); switch (nbt.func_150303_d()) { case 6: for (int i = 0; i < count; i++) list.add(new DataDouble(nbt.func_150309_d(i))); break; case 5: for (int i = 0; i < count; i++) list.add(new DataFloat(nbt.func_150308_e(i))); break; case 8: for (int i = 0; i < count; i++) list.add(new DataString(nbt.getStringTagAt(i))); break; case 10: for (int i = 0; i < count; i++) list.add(create(nbt.getCompoundTagAt(i))); break; case 11: for (int i = 0; i < count; i++) list.add(new DataIntegerArray(nbt.func_150306_c(i))); break; } return list; }
/** (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); this.setCanPickUpLoot(par1NBTTagCompound.getBoolean("CanPickUpLoot")); this.persistenceRequired = par1NBTTagCompound.getBoolean("PersistenceRequired"); if (par1NBTTagCompound.func_150297_b("CustomName", 8) && par1NBTTagCompound.getString("CustomName").length() > 0) { this.setCustomNameTag(par1NBTTagCompound.getString("CustomName")); } this.setAlwaysRenderNameTag(par1NBTTagCompound.getBoolean("CustomNameVisible")); NBTTagList var2; int var3; if (par1NBTTagCompound.func_150297_b("Equipment", 9)) { var2 = par1NBTTagCompound.getTagList("Equipment", 10); for (var3 = 0; var3 < this.equipment.length; ++var3) { this.equipment[var3] = ItemStack.loadItemStackFromNBT(var2.getCompoundTagAt(var3)); } } if (par1NBTTagCompound.func_150297_b("DropChances", 9)) { var2 = par1NBTTagCompound.getTagList("DropChances", 5); for (var3 = 0; var3 < var2.tagCount(); ++var3) { this.equipmentDropChances[var3] = var2.func_150308_e(var3); } } this.isLeashed = par1NBTTagCompound.getBoolean("Leashed"); if (this.isLeashed && par1NBTTagCompound.func_150297_b("Leash", 10)) { this.field_110170_bx = par1NBTTagCompound.getCompoundTag("Leash"); } }