Package net.minecraft.nbt

Examples of net.minecraft.nbt.NBTTagList


      internalInv[index] = Utils.readStackFromNBT( tag );
    }
  }

  public void writeToNBT(NBTTagCompound compound) {
    NBTTagList list = new NBTTagList();
    for( int i = 0; i < internalInv.length; i++ ) {
      if( internalInv[i] != null && internalInv[i].stackSize > 0 ) {
        NBTTagCompound tag = new NBTTagCompound();
        list.appendTag( tag );
        tag.setInteger( "index", i );
        internalInv[i].writeToNBT( tag );
      }
    }
    NBTTagCompound ownTag = new NBTTagCompound();
View Full Code Here


  public static CraftRecipe readFromNBT(NBTTagCompound nbtCompound) {
    NBTTagCompound compound = (NBTTagCompound) nbtCompound.getTag( "encodedRecipe" );
    if( compound == null ) return null;

    ItemStack[] ingredients = new ItemStack[9];
    NBTTagList tagList = compound.getTagList( "recipeIngredients" );
    if( tagList == null )
      return null;
    for( int i = 0; i < tagList.tagCount(); i++ ) {
      NBTTagCompound tag = (NBTTagCompound) tagList.tagAt( i );
      int index = tag.getInteger( "index" );
      ingredients[index] = Utils.readStackFromNBT( tag );
    }

    NBTTagCompound stackTag = (NBTTagCompound) compound.getTag( "recipeResult" );
View Full Code Here

  public void writeToNBT(NBTTagCompound compound) {
    NBTTagCompound nbt = new NBTTagCompound();

    // Write the ingredients.
    NBTTagList list1 = new NBTTagList();
    for( ItemStack stack : this ) {
      NBTTagCompound tag = new NBTTagCompound();
      Utils.writeItemStackToNBT( nbt, stack, "ingredient" );
      list1.appendTag( tag );
    }
    nbt.setTag( "ingredientList", list1 );

    // Write the recipes
    NBTTagList list2 = new NBTTagList();
    for( ItemsReference key : recipes.keySet() ) {
      NBTTagCompound tag = new NBTTagCompound();
      Utils.writeItemStackToNBT( nbt, key.toItemStack(), "key" );
      recipes.get( key ).writeToNBT( tag );
      list2.appendTag( tag );
    }
    nbt.setTag( "recipes", list2 );

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

    // Result
    NBTTagCompound result = new NBTTagCompound();
    recipe.result.writeToNBT( result );

    // Ingredients
    NBTTagList listIngredients = new NBTTagList();
    ItemStack[] ingredients = recipe.ingredients;
    int i;
    for( i = 0; i < ingredients.length; i++ ) {
      NBTTagCompound tag = new NBTTagCompound();
      if( ingredients[i] != null ) {
        tag.setInteger( "index", i );
        ingredients[i].writeToNBT( tag );
        listIngredients.appendTag( tag );
      }
    }

    // Actual encoding
    NBTTagCompound recipeCompound = new NBTTagCompound( "encodedRecipe" );
View Full Code Here

    NBTTagCompound nbt = (NBTTagCompound) compound.getTag( "projectList" );
    if( nbt == null )
      return;

    // Read the ingredients.
    NBTTagList list1 = nbt.getTagList( "ingredientList" );
    for( int i = 0; i < list1.tagCount(); i++ ) {
      NBTTagCompound tag = (NBTTagCompound) list1.tagAt( i );
      ItemStack item = Utils.readStackFromNBT( (NBTTagCompound) tag.getTag( "ingredient" ) );
      if( item != null )
        ingredients.addStack( item );
    }

    // Read the recipes.
    NBTTagList list2 = nbt.getTagList( "recipes" );
    for( int i = 0; i < list2.tagCount(); i++ ) {
      NBTTagCompound tag = (NBTTagCompound) list2.tagAt( i );
      ItemStack key = Utils.readStackFromNBT( (NBTTagCompound) tag.getTag( "key" ) );
      if( key != null ) {
        CraftRecipe recipe = CraftRecipe.readFromNBT( tag );
        recipes.put( key, recipe );
      }
View Full Code Here

          EnumChatFormatting.RESET));

    } else if(te instanceof IConduitBundle) {
      NBTTagCompound nbtRoot = accessor.getNBTData();
      short nbtVersion = nbtRoot.getShort("nbtVersion");
      NBTTagList conduitTags = (NBTTagList) nbtRoot.getTag("conduits");

      if(conduitTags != null) {
        for (int i = 0; i < conduitTags.tagCount(); i++) {
          NBTTagCompound conduitTag = conduitTags.getCompoundTagAt(i);
          IConduit conduit = ConduitUtil.readConduitFromNBT(conduitTag, nbtVersion);
          if(conduit != null && conduit instanceof IPowerConduit) {
            currenttip.add(String.format("%s%s%s / %s%s%s RF", EnumChatFormatting.WHITE, fmt.format(((IPowerConduit) conduit).getEnergyStored()), EnumChatFormatting.RESET,
                EnumChatFormatting.WHITE, fmt.format(((IConduitBundle) te).getMaxEnergyStored()), EnumChatFormatting.RESET));
          }
View Full Code Here

   */
  @Override
  public void writeToNBT(NBTTagCompound nbtRoot) {
    NBTTagCompound stackRoot;

    NBTTagList inputItems = new NBTTagList();
    for (MachineRecipeInput ri : inputs) {
      stackRoot = new NBTTagCompound();
      ri.writeToNbt(stackRoot);
      inputItems.appendTag(stackRoot);
    }

    nbtRoot.setTag(KEY_INPUT_STACKS, inputItems);

    nbtRoot.setString(KEY_RECIPE, recipe.getUid());
View Full Code Here

    IMachineRecipe recipe;

    float usedEnergy = nbtRoot.getFloat(KEY_USED_ENERGY);
    float chance = nbtRoot.getFloat(KEY_CHANCE);

    NBTTagList inputItems = (NBTTagList) nbtRoot.getTag(KEY_INPUT_STACKS);
    if(inputItems == null) {
      return null;
    }

    List<MachineRecipeInput> ins = new ArrayList<MachineRecipeInput>(3);
    for (int i = 0; i < inputItems.tagCount(); i++) {
      NBTTagCompound stackTag = inputItems.getCompoundTagAt(i);
      MachineRecipeInput mi = MachineRecipeInput.readFromNBT(stackTag);
      ins.add(mi);
    }

    String uid = nbtRoot.getString(KEY_RECIPE);
View Full Code Here

  }

  private void loadCartsToSpawn() {
    World worldObj = transciever.getWorldObj();
    while (cartList.tagCount() > 0) {
      NBTTagList entityList = (NBTTagList) cartList.removeTag(0);
      List<Entity> ents = new ArrayList<Entity>(entityList.tagCount());
      for (int i = 0; i < entityList.tagCount(); i++) {
        NBTTagCompound entityRoot = entityList.getCompoundTagAt(i);
        Entity entity = EntityList.createEntityFromNBT(entityRoot, worldObj);
        if(entity != null) {
          ents.add(entity);
        }
      }
View Full Code Here

    }
    cartList = (NBTTagList) root.getTag("cartList");

    newlySpawnedCarts.clear();
    if(root.hasKey("newlySpawnedCarts")) {
      NBTTagList spawnedCartList = (NBTTagList) root.getTag("newlySpawnedCarts");
      for (int i = 0; i < spawnedCartList.tagCount(); i++) {
        String uuisStr = spawnedCartList.getStringTagAt(i);
        newlySpawnedCarts.add(UUID.fromString(uuisStr));
      }
    }
  }
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.