Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public EntityClone(World world) {
- super(world);
- }
- public EntityClone(World world, EntityPlayer player) {
- super(world);
- // this.c_inventoryContainer = new ContainerPlayer(this.c_inventory, !world.isRemote, this);
- this.c_openContainer = this.c_inventoryContainer;
- this.p_profile = player.getGameProfile();
- this.p_profile = func_152109_d(this.p_profile);
- this.c_profile = this.p_profile;
- this.setHealth(player.getHealth());
- setPosition(player.posX, player.posY, player.posZ);
- NBTTagCompound comp = new NBTTagCompound();
- player.writeToNBT(comp);
- m_playerNBT = comp;
- NBTTagList invnbt = comp.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
- this.p_inventoryNBT = invnbt;
- ItemStack item;
- this.c_equipmentStack[0] = player.getCurrentEquippedItem();
- for (int i = 1; i < 5; i++) {
- item = player.getEquipmentInSlot(i);
- this.c_equipmentStack[i] = player.getEquipmentInSlot(i);
- }
- for (int j = 0; j < this.equipmentDropChances.length; ++j) {
- this.equipmentDropChances[j] = 0.0F;
- }
- // this.c_inventory.copyInventory(player.inventory);
- NBTTagList nbttaglist1 = comp.getTagList("Inventory", 10);
- this.c_inventory.readFromNBT(nbttaglist1);
- NBTTagList comp2 = new NBTTagList();
- this.writeToNBT(comp2);
- c_inventoryNBT = comp2;
- if (comp.hasKey("Inventory", 9)) {
- nbttaglist1 = comp.getTagList("Inventory", 10);
- for (int i = 0; i < nbttaglist1.tagCount(); ++i) {
- NBTTagCompound nbttagcompound = nbttaglist1.getCompoundTagAt(i);
- int j = nbttagcompound.getByte("Slot") & 255;
- ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);
- if (itemstack != null) {
- if (j >= 0 && j < this.c_inventoryStack.length) {
- this.c_inventoryStack[j] = itemstack;
- }
- if (j >= 100 && j < this.c_armourStack.length + 100) {
- this.c_armourStack[j - 100] = itemstack;
- }
- }
- }
- }
- }
- @Override
- public void readEntityFromNBT(NBTTagCompound nbt) {
- super.readEntityFromNBT(nbt);
- NBTTagList nbttaglist = nbt.getTagList("Inventory", 10);
- this.c_inventory.readFromNBT(nbttaglist);
- if (nbt.hasKey("Inventory", 9)) {
- nbttaglist = nbt.getTagList("Inventory", 10);
- for (int i = 0; i < nbttaglist.tagCount(); ++i) {
- NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
- int j = nbttagcompound.getByte("Slot") & 255;
- ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);
- if (itemstack != null) {
- if (j >= 0 && j < this.c_inventoryStack.length) {
- this.c_inventoryStack[j] = itemstack;
- }
- if (j >= 100 && j < this.c_armourStack.length + 100) {
- this.c_armourStack[j - 100] = itemstack;
- }
- }
- }
- }
- if (nbt.hasKey("Owner", 10)) {
- this.c_profile = NBTUtil.func_152459_a(nbt.getCompoundTag("Owner"));
- }
- this.func_152109_d(this.c_profile);
- NBTTagList nbttaglist1;
- int i;
- if (nbt.hasKey("Equipment", 9)) {
- nbttaglist1 = nbt.getTagList("Equipment", 10);
- for (i = 0; i < this.c_equipmentStack.length; ++i) {
- this.c_equipmentStack[i] = ItemStack.loadItemStackFromNBT(nbttaglist1.getCompoundTagAt(i));
- }
- }
- if (nbt.hasKey("DropChances", 9)) {
- nbttaglist = nbt.getTagList("DropChances", 5);
- for (i = 0; i < nbttaglist.tagCount(); ++i) {
- this.equipmentDropChances[i] = nbttaglist.func_150308_e(i);
- }
- }
- }
- @Override
- public void writeEntityToNBT(NBTTagCompound nbt) {
- super.writeEntityToNBT(nbt);
- nbt.setTag("Inventory", this.c_inventory.writeToNBT(new NBTTagList()));
- NBTTagList nbttaglist = new NBTTagList();
- NBTTagCompound nbttagcompound1;
- for (int i = 0; i < this.c_equipmentStack.length; ++i) {
- nbttagcompound1 = new NBTTagCompound();
- if (this.c_equipmentStack[i] != null) {
- this.c_equipmentStack[i].writeToNBT(nbttagcompound1);
- }
- nbttaglist.appendTag(nbttagcompound1);
- }
- nbt.setTag("Equipment", nbttaglist);
- NBTTagList nbttaglist1 = new NBTTagList();
- for (int j = 0; j < this.equipmentDropChances.length; ++j) {
- nbttaglist1.appendTag(new NBTTagFloat(this.equipmentDropChances[j]));
- }
- nbt.setTag("DropChances", nbttaglist1);
- if (this.p_profile != null) {
- NBTTagCompound nbt2 = new NBTTagCompound();
- NBTUtil.func_152460_a(nbt2, this.p_profile);
- nbt.setTag("Owner", nbt2);
- } else {
- NBTTagCompound nbt2 = new NBTTagCompound();
- NBTUtil.func_152460_a(nbt2, this.c_profile);
- nbt.setTag("Owner", nbt2);
- }
- }
- public NBTTagList writeToNBT(NBTTagList p_70442_1_) {
- int i;
- NBTTagCompound nbttagcompound;
- for (i = 0; i < this.c_inventoryStack.length; ++i) {
- if (this.c_inventoryStack[i] != null) {
- nbttagcompound = new NBTTagCompound();
- nbttagcompound.setByte("Slot", (byte) i);
- this.c_inventoryStack[i].writeToNBT(nbttagcompound);
- p_70442_1_.appendTag(nbttagcompound);
- }
- }
- for (i = 0; i < this.c_armourStack.length; ++i) {
- if (this.c_armourStack[i] != null) {
- nbttagcompound = new NBTTagCompound();
- nbttagcompound.setByte("Slot", (byte) (i + 100));
- this.c_armourStack[i].writeToNBT(nbttagcompound);
- p_70442_1_.appendTag(nbttagcompound);
- }
- }
- return p_70442_1_;
- }
- @Override
- public void readSpawnData(ByteBuf additionalData) {
- NBTTagCompound compound;
- compound = ByteBufUtils.readTag(additionalData);
- this.c_profile = NBTUtil.func_152459_a(compound.getCompoundTag("Owner"));
- this.func_152109_d(this.c_profile);
- this.c_profile = NBTUtil.func_152459_a(compound.getCompoundTag("Inventory"));
- }
- @Override
- public void writeSpawnData(ByteBuf buffer) {
- NBTTagCompound compound = new NBTTagCompound();
- NBTTagCompound cmp = new NBTTagCompound();
- NBTUtil.func_152460_a(cmp, this.c_profile);
- compound.setTag("Owner", cmp);
- compound.setTag("Inventory", cmp);
- ByteBufUtils.writeTag(buffer, compound);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement