Package net.minecraft.nbt

Examples of net.minecraft.nbt.NBTTagList


    return facing;
  }

  @Override
  protected void writeCustomNBT(NBTTagCompound root) {
    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);
      }
    }
    root.setTag("Items", itemList);
    root.setShort("facing", facing);
  }
View Full Code Here


    root.setShort("facing", facing);
  }

  @Override
  protected void readCustomNBT(NBTTagCompound root) {
    NBTTagList itemList = (NBTTagList) root.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

    }

    if(!nbtRoot.hasKey(key)) {
      return;
    }
    NBTTagList tags = (NBTTagList) nbtRoot.getTag(key);
    for (int i = 0; i < tags.tagCount(); i++) {
      NBTTagCompound chanelTag = tags.getCompoundTagAt(i);
      Channel channel = Channel.readFromNBT(chanelTag);
      if(channel != null) {
        readInto.get(channel.getType()).add(channel);
      }
    }
View Full Code Here

  @Override
  public void writeCommon(NBTTagCompound nbtRoot) {
    super.writeCommon(nbtRoot);

    NBTTagList channelTags = createTagList(sendChannels);
    nbtRoot.setTag("sendChannels", channelTags);

    channelTags = createTagList(recieveChannels);
    nbtRoot.setTag("recieveChannels", channelTags);
  }
View Full Code Here

    channelTags = createTagList(recieveChannels);
    nbtRoot.setTag("recieveChannels", channelTags);
  }

  static NBTTagList createTagList(EnumMap<ChannelType, List<Channel>> chans) {
    NBTTagList res = new NBTTagList();
    for (List<Channel> chanList : chans.values()) {
      for (Channel channel : chanList) {
        NBTTagCompound chanTag = new NBTTagCompound();
        channel.writeToNBT(chanTag);
        res.appendTag(chanTag);
      }
    }
    return res;
  }
View Full Code Here

    if(isEmpty()) {
      root.removeTag("fluidFilter");
      return;
    }

    NBTTagList fluidList = new NBTTagList();
    int index = 0;
    for (Fluid f : fluids) {
      if(f != null) {
        NBTTagCompound fRoot = new NBTTagCompound();
        fRoot.setInteger("index", index);
        fRoot.setString("fluidName", f.getName());
        fluidList.appendTag(fRoot);
      }
      index++;
    }
    root.setTag("fluidFilter", fluidList);
View Full Code Here

  public void readFromNBT(NBTTagCompound root) {
    if(!root.hasKey("fluidFilter")) {
      clear();
      return;
    }
    NBTTagList fluidList = (NBTTagList) root.getTag("fluidFilter");
    for (int i = 0; i < fluidList.tagCount(); i++) {
      NBTTagCompound fRoot = fluidList.getCompoundTagAt(i);
      setFluid(fRoot.getInteger("index"), fRoot.getString("fluidName"));
    }
  }
View Full Code Here

  }

  @Override
  public void writeToNBT(NBTTagCompound nbtRoot) {
    super.writeToNBT(nbtRoot);
    NBTTagList list = new NBTTagList();
    for (ForgeDirection dir : validConnections) {
      NBTTagString name = new NBTTagString(dir.name());
      list.appendTag(name);
    }
    nbtRoot.setTag("validConnections", list);
  }
View Full Code Here

  @Override
  public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) {
    super.readFromNBT(nbtRoot, nbtVersion);
    if(nbtRoot.hasKey("validConnections")) {
      validConnections.clear();
      NBTTagList connections = nbtRoot.getTagList("validConnections", Constants.NBT.TAG_STRING);
      for (int i = 0; i < connections.tagCount(); i++) {
        validConnections.add(ForgeDirection.valueOf(connections.getStringTagAt(i)));
      }
    }
  }
View Full Code Here

    useOreDict = nbtRoot.getBoolean("useOreDict");
    sticky = nbtRoot.getBoolean("sticky");
   
    if(nbtRoot.hasKey("snapshot")) {
      snapshot = new ArrayList<ItemStack>();
      NBTTagList itemList = (NBTTagList)nbtRoot.getTag("snapshot");
      for(int i=0;i<itemList.tagCount();i++) {
        NBTTagCompound itemTag = itemList.getCompoundTagAt(i);
        ItemStack itemStack = ItemStack.loadItemStackFromNBT(itemTag);
        if(itemStack != null) {
          snapshot.add(itemStack);
        }
      }
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.