Esempio n. 1
0
  public void importOldChunkTileEntities() {
    File file = wc.downloadSaveHandler.getSaveDirectory();
    if (wc.worldProvider instanceof WorldProviderHell) {
      file = new File(file, "DIM-1");
      file.mkdirs();
    }

    java.io.DataInputStream datainputstream =
        RegionFileCache.getChunkInputStream(file, xPosition, zPosition);
    NBTTagCompound nbttagcompound;
    if (datainputstream != null) {
      try {
        nbttagcompound = CompressedStreamTools.func_1141_a(datainputstream);
      } catch (IOException e) {
        return;
      }
    } else return;

    if (!nbttagcompound.hasKey("Level")) return;

    NBTTagList nbttaglist1 = nbttagcompound.getCompoundTag("Level").getTagList("TileEntities");
    if (nbttaglist1 != null) {
      for (int l = 0; l < nbttaglist1.tagCount(); l++) {
        NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist1.tagAt(l);
        TileEntity te = TileEntity.createAndLoadEntity(nbttagcompound2);
        if (te != null) {
          ChunkPosition cp = new ChunkPosition(te.xCoord & 0xf, te.yCoord, te.zCoord & 0xf);
          newChunkTileEntityMap.put(cp, te);
        }
      }
    }
  }
  protected void b(NBTTagCompound nbttagcompound) {
    NBTTagList nbttaglist = nbttagcompound.getList("Entrances", 11);

    for (int i = 0; i < nbttaglist.size(); ++i) {
      this.a.add(new StructureBoundingBox(nbttaglist.c(i)));
    }
  }
  public static void a(Map map, ItemStack itemstack) {
    NBTTagList nbttaglist = new NBTTagList();
    Iterator iterator = map.keySet().iterator();

    while (iterator.hasNext()) {
      int i = ((Integer) iterator.next()).intValue();
      NBTTagCompound nbttagcompound = new NBTTagCompound();

      nbttagcompound.setShort("id", (short) i);
      nbttagcompound.setShort("lvl", (short) ((Integer) map.get(Integer.valueOf(i))).intValue());
      nbttaglist.add(nbttagcompound);
      if (itemstack.getItem() == Items.ENCHANTED_BOOK) {
        Items.ENCHANTED_BOOK.a(
            itemstack,
            new EnchantmentInstance(i, ((Integer) map.get(Integer.valueOf(i))).intValue()));
      }
    }

    if (nbttaglist.size() > 0) {
      if (itemstack.getItem() != Items.ENCHANTED_BOOK) {
        itemstack.a("ench", (NBTBase) nbttaglist);
      }
    } else if (itemstack.hasTag()) {
      itemstack.getTag().remove("ench");
    }
  }
Esempio n. 4
0
  /** write data to NBTTagCompound from this MapDataBase, similar to Entities and TileEntities */
  public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
    // DEBUG
    System.out.println("MapData.writeToNBT()");

    par1NBTTagCompound.setInteger("dimension", this.dimension);
    par1NBTTagCompound.setInteger("xCenter", this.xCenter);
    par1NBTTagCompound.setInteger("zCenter", this.zCenter);
    par1NBTTagCompound.setByte("scale", this.scale);
    par1NBTTagCompound.setShort("width", (short) 128);
    par1NBTTagCompound.setShort("height", (short) 128);
    par1NBTTagCompound.setByteArray("colors", this.colors);

    // CartoCraft - Save custom icons
    if (this.customIcons.size() > 0) {
      NBTTagList iconTagList = new NBTTagList();
      NBTTagCompound iconTagCompound;
      MapCoord mapcoord;

      for (Iterator iterator = this.customIcons.values().iterator(); iterator.hasNext(); ) {
        mapcoord = (MapCoord) iterator.next();

        iconTagCompound = new NBTTagCompound();
        iconTagCompound.setByte("icon", mapcoord.iconSize);
        iconTagCompound.setByte("xPos", mapcoord.centerX);
        iconTagCompound.setByte("zPos", mapcoord.centerZ);

        iconTagList.appendTag(iconTagCompound);
      }
      par1NBTTagCompound.setTag("customIcons", iconTagList);
    }
  }
  protected NBTTagList func_96496_a() {
    NBTTagList var1 = new NBTTagList();
    Collection var2 = this.field_96507_a.func_96525_g();
    Iterator var3 = var2.iterator();

    while (var3.hasNext()) {
      ScorePlayerTeam var4 = (ScorePlayerTeam) var3.next();
      NBTTagCompound var5 = new NBTTagCompound();
      var5.setString("Name", var4.func_96661_b());
      var5.setString("DisplayName", var4.func_96669_c());
      var5.setString("Prefix", var4.func_96668_e());
      var5.setString("Suffix", var4.func_96663_f());
      var5.setBoolean("AllowFriendlyFire", var4.func_96665_g());
      var5.setBoolean("SeeFriendlyInvisibles", var4.func_98297_h());
      NBTTagList var6 = new NBTTagList();
      Iterator var7 = var4.func_96670_d().iterator();

      while (var7.hasNext()) {
        String var8 = (String) var7.next();
        var6.appendTag(new NBTTagString("", var8));
      }

      var5.setTag("Players", var6);
      var1.appendTag(var5);
    }

    return var1;
  }
Esempio n. 6
0
  public void a(NBTTagCompound nbttagcompound) {
    super.a(nbttagcompound);
    this.o(nbttagcompound.getBoolean("EatingHaystack"));
    this.k(nbttagcompound.getBoolean("Bred"));
    this.setHasChest(nbttagcompound.getBoolean("ChestedHorse"));
    this.m(nbttagcompound.getBoolean("HasReproduced"));
    this.setType(nbttagcompound.getInt("Type"));
    this.setVariant(nbttagcompound.getInt("Variant"));
    this.setTemper(nbttagcompound.getInt("Temper"));
    this.setTame(nbttagcompound.getBoolean("Tame"));
    if (nbttagcompound.hasKeyOfType("OwnerUUID", 8)) {
      this.setOwnerUUID(nbttagcompound.getString("OwnerUUID"));
    }
    // CraftBukkit start
    if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) {
      this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
    }
    // CraftBukkit end
    AttributeInstance attributeinstance = this.bb().a("Speed");

    if (attributeinstance != null) {
      this.getAttributeInstance(GenericAttributes.d).setValue(attributeinstance.b() * 0.25D);
    }

    if (this.hasChest()) {
      NBTTagList nbttaglist = nbttagcompound.getList("Items", 10);

      this.loadChest();

      for (int i = 0; i < nbttaglist.size(); ++i) {
        NBTTagCompound nbttagcompound1 = nbttaglist.get(i);
        int j = nbttagcompound1.getByte("Slot") & 255;

        if (j >= 2 && j < this.inventoryChest.getSize()) {
          this.inventoryChest.setItem(j, ItemStack.createStack(nbttagcompound1));
        }
      }
    }

    ItemStack itemstack;

    if (nbttagcompound.hasKeyOfType("ArmorItem", 10)) {
      itemstack = ItemStack.createStack(nbttagcompound.getCompound("ArmorItem"));
      if (itemstack != null && a(itemstack.getItem())) {
        this.inventoryChest.setItem(1, itemstack);
      }
    }

    if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) {
      itemstack = ItemStack.createStack(nbttagcompound.getCompound("SaddleItem"));
      if (itemstack != null && itemstack.getItem() == Items.SADDLE) {
        this.inventoryChest.setItem(0, itemstack);
      }
    } else if (nbttagcompound.getBoolean("Saddle")) {
      this.inventoryChest.setItem(0, new ItemStack(Items.SADDLE));
    }

    this.cO();
  }
 protected void func_96500_c(NBTTagList par1NBTTagList) {
   for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) {
     NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2);
     ScoreObjective var4 = this.field_96507_a.func_96518_b(var3.getString("Objective"));
     Score var5 = this.field_96507_a.func_96529_a(var3.getString("Name"), var4);
     var5.func_96647_c(var3.getInteger("Score"));
   }
 }
Esempio n. 8
0
  public void b(ICommandListener icommandlistener, String[] astring) {
    if (astring.length < 2) {
      throw new ExceptionUsage("commands.enchant.usage", new Object[0]);
    } else {
      EntityPlayer entityplayer = d(icommandlistener, astring[0]);
      int i = a(icommandlistener, astring[1], 0, Enchantment.byId.length - 1);
      int j = 1;
      ItemStack itemstack = entityplayer.bx();

      if (itemstack == null) {
        throw new CommandException("commands.enchant.noItem", new Object[0]);
      } else {
        Enchantment enchantment = Enchantment.byId[i];

        if (enchantment == null) {
          throw new ExceptionInvalidNumber(
              "commands.enchant.notFound", new Object[] {Integer.valueOf(i)});
        } else if (!enchantment.canEnchant(itemstack)) {
          throw new CommandException("commands.enchant.cantEnchant", new Object[0]);
        } else {
          if (astring.length >= 3) {
            j =
                a(
                    icommandlistener,
                    astring[2],
                    enchantment.getStartLevel(),
                    enchantment.getMaxLevel());
          }

          if (itemstack.hasTag()) {
            NBTTagList nbttaglist = itemstack.getEnchantments();

            if (nbttaglist != null) {
              for (int k = 0; k < nbttaglist.size(); ++k) {
                short short1 = ((NBTTagCompound) nbttaglist.get(k)).getShort("id");

                if (Enchantment.byId[short1] != null) {
                  Enchantment enchantment1 = Enchantment.byId[short1];

                  if (!enchantment1.a(enchantment)) {
                    throw new CommandException(
                        "commands.enchant.cantCombine",
                        new Object[] {
                          enchantment.c(j),
                          enchantment1.c(((NBTTagCompound) nbttaglist.get(k)).getShort("lvl"))
                        });
                  }
                }
              }
            }
          }

          itemstack.addEnchantment(enchantment, j);
          a(icommandlistener, "commands.enchant.success", new Object[0]);
        }
      }
    }
  }
 protected void func_96501_b(NBTTagList par1NBTTagList) {
   for (int var2 = 0; var2 < par1NBTTagList.tagCount(); ++var2) {
     NBTTagCompound var3 = (NBTTagCompound) par1NBTTagList.tagAt(var2);
     ScoreObjectiveCriteria var4 =
         (ScoreObjectiveCriteria)
             ScoreObjectiveCriteria.field_96643_a.get(var3.getString("CriteriaName"));
     ScoreObjective var5 = this.field_96507_a.func_96535_a(var3.getString("Name"), var4);
     var5.func_96681_a(var3.getString("DisplayName"));
   }
 }
Esempio n. 10
0
  /** Reads the entity from NBT (calls an abstract helper method to read specialized data) */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Pos");
    NBTTagList nbttaglist1 = par1NBTTagCompound.getTagList("Motion");
    NBTTagList nbttaglist2 = par1NBTTagCompound.getTagList("Rotation");
    motionX = ((NBTTagDouble) nbttaglist1.tagAt(0)).data;
    motionY = ((NBTTagDouble) nbttaglist1.tagAt(1)).data;
    motionZ = ((NBTTagDouble) nbttaglist1.tagAt(2)).data;

    if (Math.abs(motionX) > 10D) {
      motionX = 0.0D;
    }

    if (Math.abs(motionY) > 10D) {
      motionY = 0.0D;
    }

    if (Math.abs(motionZ) > 10D) {
      motionZ = 0.0D;
    }

    prevPosX = lastTickPosX = posX = ((NBTTagDouble) nbttaglist.tagAt(0)).data;
    prevPosY = lastTickPosY = posY = ((NBTTagDouble) nbttaglist.tagAt(1)).data;
    prevPosZ = lastTickPosZ = posZ = ((NBTTagDouble) nbttaglist.tagAt(2)).data;
    prevRotationYaw = rotationYaw = ((NBTTagFloat) nbttaglist2.tagAt(0)).data;
    prevRotationPitch = rotationPitch = ((NBTTagFloat) nbttaglist2.tagAt(1)).data;
    fallDistance = par1NBTTagCompound.getFloat("FallDistance");
    fire = par1NBTTagCompound.getShort("Fire");
    setAir(par1NBTTagCompound.getShort("Air"));
    onGround = par1NBTTagCompound.getBoolean("OnGround");
    setPosition(posX, posY, posZ);
    setRotation(rotationYaw, rotationPitch);
    readEntityFromNBT(par1NBTTagCompound);
  }
Esempio n. 11
0
  /** creates a NBT list from the array of doubles passed to this function */
  protected NBTTagList newDoubleNBTList(double par1ArrayOfDouble[]) {
    NBTTagList nbttaglist = new NBTTagList();
    double ad[] = par1ArrayOfDouble;
    int i = ad.length;

    for (int j = 0; j < i; j++) {
      double d = ad[j];
      nbttaglist.appendTag(new NBTTagDouble(null, d));
    }

    return nbttaglist;
  }
Esempio n. 12
0
 public void func_482_a(NBTTagCompound p_482_1_) {
   super.func_482_a(p_482_1_);
   NBTTagList nbttaglist = p_482_1_.func_753_l("Items");
   field_21102_a = new ItemStack[func_469_c()];
   for (int i = 0; i < nbttaglist.func_740_c(); i++) {
     NBTTagCompound nbttagcompound = (NBTTagCompound) nbttaglist.func_741_a(i);
     int j = nbttagcompound.func_746_c("Slot") & 0xff;
     if (j >= 0 && j < field_21102_a.length) {
       field_21102_a[j] = ItemStack.func_35864_a(nbttagcompound);
     }
   }
 }
  protected void a(NBTTagCompound nbttagcompound) {
    NBTTagList nbttaglist = new NBTTagList();
    Iterator iterator = this.a.iterator();

    while (iterator.hasNext()) {
      StructureBoundingBox structureboundingbox = (StructureBoundingBox) iterator.next();

      nbttaglist.add(structureboundingbox.h());
    }

    nbttagcompound.set("Entrances", nbttaglist);
  }
  public void b(NBTTagCompound nbttagcompound) {
    super.b(nbttagcompound);
    if (nbttagcompound.hasKeyOfType("Processed", 9)) {
      NBTTagList nbttaglist = nbttagcompound.getList("Processed", 10);

      for (int i = 0; i < nbttaglist.size(); ++i) {
        NBTTagCompound nbttagcompound1 = nbttaglist.get(i);

        this.c.add(new ChunkCoordIntPair(nbttagcompound1.getInt("X"), nbttagcompound1.getInt("Z")));
      }
    }
  }
Esempio n. 15
0
  /** creates a NBT list from the array of floats passed to this function */
  protected NBTTagList newFloatNBTList(float par1ArrayOfFloat[]) {
    NBTTagList nbttaglist = new NBTTagList();
    float af[] = par1ArrayOfFloat;
    int i = af.length;

    for (int j = 0; j < i; j++) {
      float f = af[j];
      nbttaglist.appendTag(new NBTTagFloat(null, f));
    }

    return nbttaglist;
  }
Esempio n. 16
0
 public void readFromNBT(NBTTagCompound nbttagcompound) {
   super.readFromNBT(nbttagcompound);
   woodType = nbttagcompound.getByte("woodType");
   NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
   storage = new ItemStack[getSizeInventory()];
   for (int i = 0; i < nbttaglist.tagCount(); i++) {
     NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
     byte byte0 = nbttagcompound1.getByte("Slot");
     if (byte0 >= 0 && byte0 < storage.length) {
       storage[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
     }
   }
 }
Esempio n. 17
0
  protected NBTTagList a(float... afloat) {
    NBTTagList nbttaglist = new NBTTagList();
    float[] afloat1 = afloat;
    int i = afloat.length;

    for (int j = 0; j < i; ++j) {
      float f = afloat1[j];

      nbttaglist.add(new NBTTagFloat(f));
    }

    return nbttaglist;
  }
Esempio n. 18
0
  protected NBTTagList a(float af1[]) {
    NBTTagList nbttaglist = new NBTTagList();
    float af2[] = af1;
    int i1 = af2.length;

    for (int j1 = 0; j1 < i1; j1++) {
      float f1 = af2[j1];

      nbttaglist.a(new NBTTagFloat(f1));
    }

    return nbttaglist;
  }
Esempio n. 19
0
  protected NBTTagList a(double ad1[]) {
    NBTTagList nbttaglist = new NBTTagList();
    double ad2[] = ad1;
    int i1 = ad2.length;

    for (int j1 = 0; j1 < i1; j1++) {
      double d1 = ad2[j1];

      nbttaglist.a(new NBTTagDouble(d1));
    }

    return nbttaglist;
  }
Esempio n. 20
0
  protected NBTTagList a(double... adouble) {
    NBTTagList nbttaglist = new NBTTagList();
    double[] adouble1 = adouble;
    int i = adouble.length;

    for (int j = 0; j < i; ++j) {
      double d0 = adouble1[j];

      nbttaglist.add(new NBTTagDouble(d0));
    }

    return nbttaglist;
  }
Esempio n. 21
0
  public void a(NBTTagCompound nbttagcompound) {
    this.m(nbttagcompound.getFloat("AbsorptionAmount"));
    if (nbttagcompound.hasKey("Attributes") && this.world != null && !this.world.isStatic) {
      GenericAttributes.a(
          this.aX(),
          nbttagcompound.getList("Attributes"),
          this.world == null ? null : this.world.getLogger());
    }

    if (nbttagcompound.hasKey("ActiveEffects")) {
      NBTTagList nbttaglist = nbttagcompound.getList("ActiveEffects");

      for (int i = 0; i < nbttaglist.size(); ++i) {
        NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.get(i);
        MobEffect mobeffect = MobEffect.b(nbttagcompound1);

        this.effects.put(Integer.valueOf(mobeffect.getEffectId()), mobeffect);
      }
    }

    // CraftBukkit start
    if (nbttagcompound.hasKey("Bukkit.MaxHealth")) {
      NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth");
      if (nbtbase.getTypeId() == 5) {
        this.getAttributeInstance(GenericAttributes.a)
            .setValue((double) ((NBTTagFloat) nbtbase).data);
      } else if (nbtbase.getTypeId() == 3) {
        this.getAttributeInstance(GenericAttributes.a)
            .setValue((double) ((NBTTagInt) nbtbase).data);
      }
    }
    // CraftBukkit end

    if (nbttagcompound.hasKey("HealF")) {
      this.setHealth(nbttagcompound.getFloat("HealF"));
    } else {
      NBTBase nbtbase = nbttagcompound.get("Health");

      if (nbtbase == null) {
        this.setHealth(this.getMaxHealth());
      } else if (nbtbase.getTypeId() == 5) {
        this.setHealth(((NBTTagFloat) nbtbase).data);
      } else if (nbtbase.getTypeId() == 2) {
        this.setHealth((float) ((NBTTagShort) nbtbase).data);
      }
    }

    this.hurtTicks = nbttagcompound.getShort("HurtTime");
    this.deathTicks = nbttagcompound.getShort("DeathTime");
    this.attackTicks = nbttagcompound.getShort("AttackTime");
  }
Esempio n. 22
0
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);
    // timeleft = nbttagcompound.getInteger("timeleft");

    NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
    metalItemStacks = new ItemStack[getSizeInventory()];
    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      byte byte0 = nbttagcompound1.getByte("Slot");
      if (byte0 >= 0 && byte0 < metalItemStacks.length) {
        metalItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }
  }
  public void readFromNBT(NBTTagCompound tagCompound) {
    if (tagCompound != null) {
      NBTTagList tagList = tagCompound.getTagList("Inventory", 10);
      for (int i = 0; i < tagList.tagCount(); ++i) {
        NBTTagCompound nbttagcompound = (NBTTagCompound) tagList.getCompoundTagAt(i);
        int j = nbttagcompound.getByte("Slot") & 255;
        ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);

        if (itemstack != null) {
          this.inventory[j] = itemstack;
        }
      }
    }
  }
Esempio n. 24
0
 public void writeToNBT(NBTTagCompound nbttagcompound) {
   super.writeToNBT(nbttagcompound);
   NBTTagList nbttaglist = new NBTTagList();
   for (int i = 0; i < storage.length; i++) {
     if (storage[i] != null) {
       NBTTagCompound nbttagcompound1 = new NBTTagCompound();
       nbttagcompound1.setByte("Slot", (byte) i);
       storage[i].writeToNBT(nbttagcompound1);
       nbttaglist.appendTag(nbttagcompound1);
     }
   }
   nbttagcompound.setTag("Items", nbttaglist);
   nbttagcompound.setByte("woodType", woodType);
 }
Esempio n. 25
0
  public void func_481_b(NBTTagCompound p_481_1_) {
    super.func_481_b(p_481_1_);
    NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < field_21102_a.length; i++) {
      if (field_21102_a[i] != null) {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.func_761_a("Slot", (byte) i);
        field_21102_a[i].func_1086_a(nbttagcompound);
        nbttaglist.func_742_a(nbttagcompound);
      }
    }

    p_481_1_.func_762_a("Items", nbttaglist);
  }
  /** Return the enchantments for the specified stack. */
  public static Map getEnchantments(ItemStack par0ItemStack) {
    LinkedHashMap var1 = new LinkedHashMap();
    NBTTagList var2 = par0ItemStack.getEnchantmentTagList();

    if (var2 != null) {
      for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
        short var4 = ((NBTTagCompound) var2.tagAt(var3)).getShort("id");
        short var5 = ((NBTTagCompound) var2.tagAt(var3)).getShort("lvl");
        var1.put(Integer.valueOf(var4), Integer.valueOf(var5));
      }
    }

    return var1;
  }
Esempio n. 27
0
 public void func_70037_a(NBTTagCompound p_70037_1_) {
   field_70231_e = p_70037_1_.func_74765_d("xTile");
   field_70228_f = p_70037_1_.func_74765_d("yTile");
   field_70229_g = p_70037_1_.func_74765_d("zTile");
   field_70237_h = p_70037_1_.func_74771_c("inTile") & 0xff;
   field_70238_i = p_70037_1_.func_74771_c("inGround") == 1;
   if (p_70037_1_.func_74764_b("direction")) {
     NBTTagList nbttaglist = p_70037_1_.func_74761_m("direction");
     field_70159_w = ((NBTTagDouble) nbttaglist.func_74743_b(0)).field_74755_a;
     field_70181_x = ((NBTTagDouble) nbttaglist.func_74743_b(1)).field_74755_a;
     field_70179_y = ((NBTTagDouble) nbttaglist.func_74743_b(2)).field_74755_a;
   } else {
     func_70106_y();
   }
 }
  public static void addBookEnchantment(ItemStack result, short id, short lvl) {
    if (result.getTagCompound() == null) {
      result.setTagCompound(new NBTTagCompound());
    }

    if (!result.getTagCompound().hasKey("StoredEnchantments")) {
      result.getTagCompound().setTag("StoredEnchantments", new NBTTagList());
    }

    NBTTagList enchList = result.getTagCompound().getTagList("StoredEnchantments", TAG_COMPOUND);
    NBTTagCompound ench = new NBTTagCompound();
    ench.setShort("id", id);
    ench.setShort("lvl", lvl);
    enchList.appendTag(ench);
  }
  /* Save/Load */
  public void saveToNBT(NBTTagCompound tagCompound) {
    NBTTagList tagList = new NBTTagList();
    NBTTagCompound invSlot;

    for (int i = 0; i < this.inventory.length; ++i) {
      if (this.inventory[i] != null) {
        invSlot = new NBTTagCompound();
        invSlot.setByte("Slot", (byte) i);
        this.inventory[i].writeToNBT(invSlot);
        tagList.appendTag(invSlot);
      }
    }

    tagCompound.setTag("Inventory", tagList);
  }
  protected void a(NBTTagCompound nbttagcompound) {
    super.a(nbttagcompound);
    NBTTagList nbttaglist = nbttagcompound.m("Items");

    this.a = new ItemStack[this.j_()];

    for (int i0 = 0; i0 < nbttaglist.c(); ++i0) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.b(i0);
      int i1 = nbttagcompound1.c("Slot") & 255;

      if (i1 >= 0 && i1 < this.a.length) {
        this.a[i1] = ItemStack.a(nbttagcompound1);
      }
    }
  }