Package net.minecraft.nbt

Examples of net.minecraft.nbt.NBTTagCompound


    nbt.setTag("entity", cpt);

    NBTTagList rq = new NBTTagList();

    for (ItemStack stack : storedRequirements) {
      NBTTagCompound sub = new NBTTagCompound();
      stack.writeToNBT(stack.writeToNBT(sub));
      sub.setInteger("id", registry.getIdForItem(stack.getItem()));
      rq.appendTag(sub);
    }

    nbt.setTag("rq", rq);
  }
View Full Code Here


    ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();

    for (int i = 0; i < rq.tagCount(); ++i) {
      try {
        NBTTagCompound sub = rq.getCompoundTagAt(i);

        if (sub.getInteger("id") >= 0) {
          // Maps the id in the blueprint to the id in the world
          sub.setInteger("id", Item.itemRegistry
              .getIDForObject(registry.getItemForId(sub
                  .getInteger("id"))));

          rqs.add(ItemStack.loadItemStackFromNBT(sub));
        } else {
          // TODO: requirement can't be retreived, this blueprint is
View Full Code Here

  public void write (NBTTagCompound nbt) {
    NBTTagList blocksMapping = new NBTTagList();

    for (Block b : idToBlock) {
      NBTTagCompound sub = new NBTTagCompound();
      sub.setString("name",
          Block.blockRegistry.getNameForObject(b));
      blocksMapping.appendTag(sub);
    }

    nbt.setTag("blocksMapping", blocksMapping);

    NBTTagList itemsMapping = new NBTTagList();

    for (Item i : idToItem) {
      NBTTagCompound sub = new NBTTagCompound();
      sub.setString("name",
          Item.itemRegistry.getNameForObject(i));
      itemsMapping.appendTag(sub);
    }

    nbt.setTag("itemsMapping", itemsMapping);

    NBTTagList entitiesMapping = new NBTTagList();

    for (Class<? extends Entity> e : idToEntity) {
      NBTTagCompound sub = new NBTTagCompound();
      sub.setString("name", e.getCanonicalName());
      entitiesMapping.appendTag(sub);
    }

    nbt.setTag("entitiesMapping", entitiesMapping);
  }
View Full Code Here

  public void read (NBTTagCompound nbt) {
    NBTTagList blocksMapping = nbt.getTagList("blocksMapping",
        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < blocksMapping.tagCount(); ++i) {
      NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
      String name = sub.getString("name");
      Block b = (Block) Block.blockRegistry.getObject(name);
      registerBlock (b);
    }

    NBTTagList itemsMapping = nbt.getTagList("itemsMapping",
        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < itemsMapping.tagCount(); ++i) {
      NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
      String name = sub.getString("name");
      Item item = (Item) Item.itemRegistry.getObject(name);
      registerItem (item);
    }

    NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping",
        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < entitiesMapping.tagCount(); ++i) {
      NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i);
      String name = sub.getString("name");
      Class<? extends Entity> e = null;

      try {
        e = (Class<? extends Entity>) Class.forName(name);
      } catch (ClassNotFoundException e1) {
View Full Code Here

    if (storedRequirements.length > 0) {
      NBTTagList rq = new NBTTagList();

      for (ItemStack stack : storedRequirements) {
        NBTTagCompound sub = new NBTTagCompound();
        stack.writeToNBT(stack.writeToNBT(sub));
        sub.setInteger("id", registry.getIdForItem(stack.getItem()));
        rq.appendTag(sub);
      }

      nbt.setTag("rq", rq);
    }
View Full Code Here

      ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();

      for (int i = 0; i < rq.tagCount(); ++i) {
        try {
          NBTTagCompound sub = rq.getCompoundTagAt(i);

          if (sub.getInteger("id") >= 0) {
            // Maps the id in the blueprint to the id in the world
            sub.setInteger("id", Item.itemRegistry
                .getIDForObject(registry.getItemForId(sub
                    .getInteger("id"))));

            rqs.add(ItemStack.loadItemStackFromNBT(sub));
          } else {
            defaultPermission = BuildingPermission.CREATIVE_ONLY;
View Full Code Here

    NBTTagList list = nbt.getTagList(nbtName,
        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < list.tagCount(); ++i) {
            NBTTagCompound invSlot = list.getCompoundTagAt(i);
            Item item = Item.getItemById(invSlot.getInteger ("id"));
            invSlot.setInteger("id", registry.getIdForItem(item));
    }
  }
View Full Code Here

    NBTTagList list = nbt.getTagList(nbtName,
        Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < list.tagCount(); ++i) {
            NBTTagCompound invSlot = list.getCompoundTagAt(i);
            Item item = registry.getItemForId(invSlot.getInteger ("id"));
            invSlot.setInteger("id", Item.getIdFromItem(item));
    }
  }
View Full Code Here

        if (block.canPlaceBlockOnSide(world, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit)) {
          if (!world.isRemote) {
            world.setBlock(mop.blockX, mop.blockY, mop.blockZ, ((ItemBlock) stack.getItem()).field_150939_a, stack.getItemDamage(), 1 | 2);
            block.onBlockPlacedBy(world, mop.blockX, mop.blockY, mop.blockZ, player, itemstack);
            NBTTagCompound tileCmp = getStackTileEntity(itemstack);
            if (tileCmp != null && !tileCmp.hasNoTags()) {
              TileEntity tile1 = TileEntity.createAndLoadEntity(tileCmp);
              tile1.xCoord = mop.blockX;
              tile1.yCoord = mop.blockY;
              tile1.zCoord = mop.blockZ;
              world.setTileEntity(mop.blockX, mop.blockY, mop.blockZ, tile1);
View Full Code Here

    ItemWandCasting wand = (ItemWandCasting) stack.getItem();
    ItemStack focus = wand.getFocusItem(stack);
    String blockName = Block.blockRegistry.getNameForObject(block);
    ItemNBTHelper.setString(focus, TAG_BLOCK_NAME, blockName);
    ItemNBTHelper.setInt(focus, TAG_BLOCK_META, meta);
    NBTTagCompound cmp = new NBTTagCompound();
    if (tile != null)
      tile.writeToNBT(cmp);
    ItemNBTHelper.setCompound(focus, TAG_TILE_CMP, cmp);
    ItemNBTHelper.setBoolean(focus, TAG_AVAILABLE, true);
    wand.setFocus(stack, focus);
View Full Code Here

TOP

Related Classes of net.minecraft.nbt.NBTTagCompound

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.