Package net.minecraft.nbt

Examples of net.minecraft.nbt.NBTTagList


  public void writeToNBT(NBTTagCompound root) {
    if(cartsToSpawn.isEmpty()) {
      return;
    }
    NBTTagList cartList = new NBTTagList();

    for (List<Entity> entsInCart : cartsToSpawn) {
      if(entsInCart != null && !entsInCart.isEmpty()) {
        NBTTagList entityList = new NBTTagList();
        cartList.appendTag(entityList);
        for (Entity entity : entsInCart) {
          NBTTagCompound entRoot = new NBTTagCompound();
          entRoot.setString("id", EntityList.getEntityString(entity));
          entity.writeToNBT(entRoot);
          entityList.appendTag(entRoot);
        }
      }
    }
    root.setTag("cartList", cartList);

    if(!newlySpawnedCarts.isEmpty()) {
      NBTTagList spawnedCartList = new NBTTagList();
      for (UUID uuid : newlySpawnedCarts) {
        spawnedCartList.appendTag(new NBTTagString(uuid.toString()));
      }
      root.setTag("newlySpawnedCarts", spawnedCartList);
    }
  }
View Full Code Here


    for (int i = 0; i < inventory.length; i++) {
      inventory[i] = null;
    }

    NBTTagList itemList = (NBTTagList) nbtRoot.getTag("Items");
    for (int i = 0; i < itemList.tagCount(); i++) {
      NBTTagCompound itemStack = itemList.getCompoundTagAt(i);
      byte slot = itemStack.getByte("Slot");
      if(slot >= 0 && slot < inventory.length) {
        inventory[slot] = ItemStack.loadItemStackFromNBT(itemStack);
      }
    }
View Full Code Here

      }
      nbtRoot.setIntArray("multiblock", vals);
    }

    // write inventory list
    NBTTagList itemList = new NBTTagList();
    for (int i = 0; i < inventory.length; i++) {
      if(inventory[i] != null) {
        NBTTagCompound itemStackNBT = new NBTTagCompound();
        itemStackNBT.setByte("Slot", (byte) i);
        inventory[i].writeToNBT(itemStackNBT);
        itemList.appendTag(itemStackNBT);
      }
    }
    nbtRoot.setTag("Items", itemList);

    //face modes
View Full Code Here

  public boolean isItemValidForSlot(int var1, ItemStack var2) {
    return var1 < 9;
  }

  public void readFromNBT(NBTTagCompound nbtRoot) {
    NBTTagList itemList = (NBTTagList) nbtRoot.getTag("Items");
    if(itemList == null) {
      for (int i = 0; i < inv.length; i++) {
        inv[i] = null;
      }
      return;
    }
    for (int i = 0; i < itemList.tagCount(); i++) {
      NBTTagCompound itemStack = itemList.getCompoundTagAt(i);
      byte slot = itemStack.getByte("Slot");
      if(slot >= 0 && slot < inv.length) {
        inv[slot] = ItemStack.loadItemStackFromNBT(itemStack);
      }
    }
View Full Code Here

      }
    }
  }

  public void writeToNBT(NBTTagCompound nbtRoot) {
    NBTTagList itemList = new NBTTagList();
    for (int i = 0; i < inv.length; i++) {
      if(inv[i] != null) {
        NBTTagCompound itemStackNBT = new NBTTagCompound();
        itemStackNBT.setByte("Slot", (byte) i);
        inv[i].writeToNBT(itemStackNBT);
        itemList.appendTag(itemStackNBT);
      }
    }
    nbtRoot.setTag("Items", itemList);
  }
View Full Code Here

    }
  }

  @Override
  public void toBytes(ByteBuf buf) {
    NBTTagList tagList = new NBTTagList();
    for(Channel chan : channels) {
      NBTTagCompound tag = new NBTTagCompound();
      chan.writeToNBT(tag);
      tagList.appendTag(tag);
    }
    NBTTagCompound root = new NBTTagCompound();
    root.setTag("chanList", tagList);
    NetworkUtil.writeNBTTagCompound(root, buf);
  }
View Full Code Here

  }

  @Override
  public void fromBytes(ByteBuf buf) {
    NBTTagCompound root = NetworkUtil.readNBTTagCompound(buf);
    NBTTagList tagList = (NBTTagList)root.getTag("chanList");
    channels = new ArrayList<Channel>();
    for(int i=0; i < tagList.tagCount();i++) {
      NBTTagCompound tag = tagList.getCompoundTagAt(i);
      Channel chan = Channel.readFromNBT(tag);
      if(chan != null) {
        channels.add(chan);
      }
    }
View Full Code Here

    super.readFromNBT(nbtRoot);   
    readContentsFromNBT(nbtRoot);
  }
 
  public void readContentsFromNBT(NBTTagCompound nbtRoot) {
    NBTTagList itemList = (NBTTagList) nbtRoot.getTag("Items");
    if(itemList != null) {
      for (int i = 0; i < itemList.tagCount(); i++) {
        NBTTagCompound itemStack = itemList.getCompoundTagAt(i);
        byte slot = itemStack.getByte("Slot");
        if(slot >= 0 && slot < inv.length) {
          inv[slot] = ItemStack.loadItemStackFromNBT(itemStack);
        }
      }
View Full Code Here

    super.writeToNBT(nbtRoot);
    writeContentsToNBT(nbtRoot);
  }
 
  public void writeContentsToNBT(NBTTagCompound nbtRoot) {
    NBTTagList itemList = new NBTTagList();
    for (int i = 0; i < inv.length; i++) {
      if(inv[i] != null) {
        NBTTagCompound itemStackNBT = new NBTTagCompound();
        itemStackNBT.setByte("Slot", (byte) i);
        inv[i].writeToNBT(itemStackNBT);
        itemList.appendTag(itemStackNBT);
      }
    }
    nbtRoot.setTag("Items", itemList);
  }
View Full Code Here

  @Override
  public void toBytes(ByteBuf buf) {
    super.toBytes(buf);
    buf.writeBoolean(isSend);

    NBTTagList tagList = TileTransceiver.createTagList(channels);
    NBTTagCompound root = new NBTTagCompound();
    root.setTag("chans", tagList);
    NetworkUtil.writeNBTTagCompound(root, buf);
  }
View Full Code Here

TOP

Related Classes of net.minecraft.nbt.NBTTagList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.