Examples of NBTTagList


Examples of net.minecraft.nbt.NBTTagList

  @Override
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);

    NBTTagList var2 = par1NBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    inventorySlots = new ItemStack[getSizeInventory()];
    for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
      NBTTagCompound var4 = var2.getCompoundTagAt(var3);
      byte var5 = var4.getByte("Slot");
      if (var5 >= 0 && var5 < inventorySlots.length)
        inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
    }
  }
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

  @Override
  public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
    super.writeToNBT(par1NBTTagCompound);

    NBTTagList var2 = new NBTTagList();
    for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
      if (inventorySlots[var3] != null) {
        NBTTagCompound var4 = new NBTTagCompound();
        var4.setByte("Slot", (byte) var3);
        inventorySlots[var3].writeToNBT(var4);
        var2.appendTag(var4);
      }
    }
    par1NBTTagCompound.setTag("Items", var2);

  }
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

    writeCustomNBT(par1NBTTagCompound);
  }

  public void readCustomNBT(NBTTagCompound par1NBTTagCompound) {
    NBTTagList var2 = par1NBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    inventorySlots = new ItemStack[getSizeInventory()];
    for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
      NBTTagCompound var4 = var2.getCompoundTagAt(var3);
      byte var5 = var4.getByte("Slot");
      if (var5 >= 0 && var5 < inventorySlots.length)
        inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
    }
  }
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

        inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
    }
  }

  public void writeCustomNBT(NBTTagCompound par1NBTTagCompound) {
    NBTTagList var2 = new NBTTagList();
    for (int var3 = 0; var3 < inventorySlots.length; ++var3) {
      if (inventorySlots[var3] != null) {
        NBTTagCompound var4 = new NBTTagCompound();
        var4.setByte("Slot", (byte) var3);
        inventorySlots[var3].writeToNBT(var4);
        var2.appendTag(var4);
      }
    }
    par1NBTTagCompound.setTag("Items", var2);
  }
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

     * Reads a tile entity from NBT.
     */
    public void readFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.readFromNBT(par1NBTTagCompound);
        NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
        this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];

        for (int var3 = 0; var3 < var2.tagCount(); ++var3)
        {
            NBTTagCompound var4 = (NBTTagCompound)var2.tagAt(var3);
            byte var5 = var4.getByte("Slot");

            if (var5 >= 0 && var5 < this.furnaceItemStacks.length)
            {
                this.furnaceItemStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

    public void writeToNBT(NBTTagCompound par1NBTTagCompound)
    {
        super.writeToNBT(par1NBTTagCompound);
        par1NBTTagCompound.setShort("BurnTime", (short)this.furnaceBurnTime);
        par1NBTTagCompound.setShort("CookTime", (short)this.furnaceCookTime);
        NBTTagList var2 = new NBTTagList();

        for (int var3 = 0; var3 < this.furnaceItemStacks.length; ++var3)
        {
            if (this.furnaceItemStacks[var3] != null)
            {
                NBTTagCompound var4 = new NBTTagCompound();
                var4.setByte("Slot", (byte)var3);
                this.furnaceItemStacks[var3].writeToNBT(var4);
                var2.appendTag(var4);
            }
        }

        par1NBTTagCompound.setTag("Items", var2);
    }
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

    setEnergyStored(energy);

    // read in the inventories contents
    inventory = new ItemStack[slotDefinition.getNumSlots()];

    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 < inventory.length) {
          inventory[slot] = ItemStack.loadItemStackFromNBT(itemStack);
        }
      }
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

  public void writeCommon(NBTTagCompound nbtRoot) {
    nbtRoot.setInteger("storedEnergyRF", storedEnergyRF);
    nbtRoot.setShort("capacitorType", (short) capacitorType.ordinal());

    // 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);

    nbtRoot.setInteger("redstoneControlMode", redstoneControlMode.ordinal());
View Full Code Here

Examples of net.minecraft.nbt.NBTTagList

          /**
           * This section is called when blocks set events are set and animation packets
           * are to be sent.
           */
          NBTTagCompound nbt = new NBTTagCompound();
          NBTTagList nbtList = new NBTTagList();

          // Number of blocks we're actually moving.
          int i = 0;

          for (Vector3 position : this.manipulationVectors)
          {
            if (this.moveBlock(position) && this.isBlockVisibleByPlayer(position) && i < Settings.MAX_FORCE_FIELDS_PER_TICK)
            {
              nbtList.appendTag(position.writeToNBT(new NBTTagCompound()));
              i++;
            }
          }

          if (i > 0)
          {
            queueEvent(new DelayedEvent(this, getMoveTime())
            {
              @Override protected void onEvent()
              {
                moveEntities();
                PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(TileForceManipulator.this, TilePacketType.FIELD.ordinal()));
              }
            });

            nbt.setByte("type", (byte) 2);
            nbt.setTag("list", nbtList);

            if (!this.isTeleport())
            {
              PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 1, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);

              if (this.getModuleCount(ModularForceFieldSystem.itemModuleSilence) <= 0)
              {
                this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "fieldmove", 0.6f, (1 - this.worldObj.rand.nextFloat() * 0.1f));
              }

              if (this.doAnchor)
              {
                this.anchor = this.anchor.translate(this.getDirection());
              }
            }
            else
            {
              PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 2, this.getMoveTime(), this.getAbsoluteAnchor().translate(0.5), this.getTargetPosition().translate(0.5).writeToNBT(new NBTTagCompound()), false, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);
              this.moveTime = this.getMoveTime();
            }
          }
          else
          {
            this.markFailMove = true;
          }

          this.manipulationVectors = null;
          this.onInventoryChanged();
        }
      }

      /**
       * While the field is being TELEPORTED ONLY.
       */
      if (this.moveTime > 0)
      {
        if (this.isTeleport() && this.requestFortron(this.getFortronCost(), true) >= this.getFortronCost())
        {
          if (this.getModuleCount(ModularForceFieldSystem.itemModuleSilence) <= 0 && this.ticks % 10 == 0)
          {
            int moveTime = this.getMoveTime();
            this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "fieldmove", 1.5f, 0.5f + 0.8f * (moveTime - this.moveTime) / moveTime);
          }

          if (--this.moveTime == 0)
          {
            this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "teleport", 0.6f, (1 - this.worldObj.rand.nextFloat() * 0.1f));
          }
        }
        else
        {
          this.markFailMove = true;
        }
      }

      /**
       * Force Manipulator activated, try start moving...
       */
      if (isActive())
      {
        markActive = true;
      }

      if (ticks % 20 == 0 && markActive)
      {
        if (moveTime <= 0 && requestFortron(this.getFortronCost(), false) > 0)
        {
          if (!worldObj.isRemote)
          {
            requestFortron(getFortronCost(), true);
            // Start multi-threading calculations
            (new ManipulatorCalculationThread(this)).start();
          }

          moveTime = 0;
        }

        if (!worldObj.isRemote)
        {
          setActive(false);
        }

        markActive = false;
      }

      /**
       * Render preview
       */
      if (!this.worldObj.isRemote)
      {
        if (!this.isCalculated)
        {
          this.calculateForceField();
        }

        // Manipulation area preview
        if (this.ticks % 120 == 0 && !this.isCalculating && Settings.HIGH_GRAPHICS && this.delayedEvents.size() <= 0 && this.displayMode > 0)
        {
          NBTTagCompound nbt = new NBTTagCompound();
          NBTTagList nbtList = new NBTTagList();

          int i = 0;
          for (Vector3 position : this.getInteriorPoints())
          {
            if (this.isBlockVisibleByPlayer(position) && (this.displayMode == 2 || !this.worldObj.isAirBlock(position.intX(), position.intY(), position.intZ()) && i < Settings.MAX_FORCE_FIELDS_PER_TICK))
            {
              i++;
              nbtList.appendTag(new Vector3(position).writeToNBT(new NBTTagCompound()));
            }
          }

          nbt.setByte("type", (byte) 1);
          nbt.setTag("list", nbtList);

          if (this.isTeleport())
          {
            Vector3 targetPosition;
            if (getTargetPosition().world == null)
            {
              targetPosition = new Vector3(getTargetPosition());
            }
            else
            {
              targetPosition = getTargetPosition();
            }

            PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 2, 60, getAbsoluteAnchor().translate(0.5), targetPosition.translate(0.5).writeToNBT(new NBTTagCompound()), true, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);
          }
          else
          {
            PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.FXS.ordinal(), (byte) 1, nbt), worldObj, new Vector3(this), PACKET_DISTANCE);
          }
        }
      }

      if (this.markFailMove)
      {
        this.moveTime = 0;
        delayedEvents.clear();
        this.worldObj.playSoundEffect(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, ModularForceFieldSystem.PREFIX + "powerdown", 0.6f, (1 - this.worldObj.rand.nextFloat() * 0.1f));
        PacketHandler.sendPacketToClients(ModularForceFieldSystem.PACKET_TILE.getPacket(this, TilePacketType.RENDER.ordinal()), this.worldObj, new Vector3(this), PACKET_DISTANCE);
        this.markFailMove = false;

        /**
         * Send failed positions to client to inform them WHICH blocks are causing the field
         * to fail.
         */
        NBTTagCompound nbt = new NBTTagCompound();
        NBTTagList nbtList = new NBTTagList();

        for (Vector3 position : this.failedPositions)
        {
          nbtList.appendTag(position.writeToNBT(new NBTTagCompound()));
        }

        nbt.setByte("type", (byte) 1);
        nbt.setTag("list", nbtList);

View Full Code Here

Examples of net.minecraft.server.NBTTagList

   * @param inventory to load
   * @param list to load from
   */
  public static void loadInventory(org.bukkit.inventory.Inventory inventory, CommonTagList list) {
    final Object inventoryHandle = Conversion.toInventoryHandle.convert(inventory);
    NBTTagList nbt = (NBTTagList) list.getHandle();
    if (inventoryHandle == null) {
      throw new IllegalArgumentException("This kind of inventory lacks a handle to save");
    } else if (inventoryHandle instanceof PlayerInventory) {
      ((PlayerInventory) inventoryHandle).b(nbt);
    } else if (inventoryHandle instanceof InventoryEnderChest) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.