Ejemplo n.º 1
0
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   super.readFromNBT(tag);
   inventory = new ArrayList<ItemStack>();
   if (tag.hasKey("inventory")) {
     NBTTagList list = tag.getTagList("inventory", Constants.NBT.TAG_COMPOUND);
     for (int i = 0; i < list.tagCount(); i++) {
       inventory.add(ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)));
     }
   }
   incenses = new ArrayList<ItemStack>();
   if (tag.hasKey("incenses")) {
     NBTTagList list = tag.getTagList("incenses", Constants.NBT.TAG_COMPOUND);
     for (int i = 0; i < list.tagCount(); i++) {
       incenses.add(ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i)));
     }
   }
   if (tag.hasKey("ritualName")) {
     ritualName = tag.getString("ritualName");
     ritual = RitualManager.getRitualFromName(ritualName);
     System.out.println("Ritual name: " + ritualName);
   }
   if (tag.hasKey("progress")) {
     progress = tag.getInteger("progress");
   }
 }
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    Utils.readStacksFromNBT(nbttagcompound, "items", items);

    energyStored = nbttagcompound.getFloat("energyStored");

    NBTTagList list = nbttagcompound.getTagList("planned");

    for (int i = 0; i < list.tagCount(); ++i) {
      NBTTagCompound cpt = (NBTTagCompound) list.tagAt(i);

      ItemStack stack = ItemStack.loadItemStackFromNBT(cpt);

      for (AssemblyRecipe r : AssemblyRecipe.assemblyRecipes) {
        if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
          plannedOutput.add(r);
        }
      }
    }

    if (nbttagcompound.hasKey("recipe")) {
      ItemStack stack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("recipe"));

      for (AssemblyRecipe r : plannedOutput) {
        if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) {
          setCurrentRecipe(r);
          break;
        }
      }
    }
  }
Ejemplo n.º 3
0
  public static ItemStack getSmelt(ItemStack smelt, ItemStack itemStack) {
    if (!itemStack.hasTagCompound() || !itemStack.getTagCompound().getBoolean("Smelt"))
      return smelt;
    NBTTagList items =
        itemStack.getTagCompound().getTagList("ItemsSmelt", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < items.tagCount(); ++i) {
      NBTTagCompound item = /*(NBTTagCompound)*/ items.getCompoundTagAt(i);
      byte slot = item.getByte("Slot");

      // Just double-checking that the saved slot index is within our inventory array bounds
      if (slot >= 0 && slot < 9) {
        if (!itemStack.getTagCompound().getBoolean("Invert")
            && ItemStack.loadItemStackFromNBT(item).isItemEqual(smelt))
          return FurnaceRecipes.smelting().getSmeltingResult(smelt) != null
              ? getOneSmelt(smelt)
              : smelt;
        else if (itemStack.getTagCompound().getBoolean("Invert")
            && !ItemStack.loadItemStackFromNBT(item).isItemEqual(smelt))
          return FurnaceRecipes.smelting().getSmeltingResult(smelt) != null
              ? getOneSmelt(smelt)
              : smelt;
      }
    }
    return smelt;
  }
  /** (abstract) Protected helper method to read subclass entity data from NBT. */
  public void readEntityFromNBT(NBTTagCompound tagCompund) {
    super.readEntityFromNBT(tagCompund);
    this.setEatingHaystack(tagCompund.getBoolean("EatingHaystack"));
    this.func_110242_l(tagCompund.getBoolean("Bred"));
    this.setChested(tagCompund.getBoolean("ChestedHorse"));
    this.setHasReproduced(tagCompund.getBoolean("HasReproduced"));
    this.setHorseType(tagCompund.getInteger("Type"));
    this.setHorseVariant(tagCompund.getInteger("Variant"));
    this.setTemper(tagCompund.getInteger("Temper"));
    this.setHorseTamed(tagCompund.getBoolean("Tame"));

    if (tagCompund.hasKey("OwnerUUID", 8)) {
      this.func_152120_b(tagCompund.getString("OwnerUUID"));
    }

    IAttributeInstance iattributeinstance =
        this.getAttributeMap().getAttributeInstanceByName("Speed");

    if (iattributeinstance != null) {
      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
          .setBaseValue(iattributeinstance.getBaseValue() * 0.25D);
    }

    if (this.isChested()) {
      NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
      this.func_110226_cD();

      for (int i = 0; i < nbttaglist.tagCount(); ++i) {
        NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
        int j = nbttagcompound1.getByte("Slot") & 255;

        if (j >= 2 && j < this.horseChest.getSizeInventory()) {
          this.horseChest.setInventorySlotContents(
              j, ItemStack.loadItemStackFromNBT(nbttagcompound1));
        }
      }
    }

    ItemStack itemstack;

    if (tagCompund.hasKey("ArmorItem", 10)) {
      itemstack = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("ArmorItem"));

      if (itemstack != null && func_146085_a(itemstack.getItem())) {
        this.horseChest.setInventorySlotContents(1, itemstack);
      }
    }

    if (tagCompund.hasKey("SaddleItem", 10)) {
      itemstack = ItemStack.loadItemStackFromNBT(tagCompund.getCompoundTag("SaddleItem"));

      if (itemstack != null && itemstack.getItem() == Items.saddle) {
        this.horseChest.setInventorySlotContents(0, itemstack);
      }
    } else if (tagCompund.getBoolean("Saddle")) {
      this.horseChest.setInventorySlotContents(0, new ItemStack(Items.saddle));
    }

    this.func_110232_cE();
  }
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    if (!nbttagcompound.hasKey("altarData")) return;

    NBTTagCompound altarCompound = nbttagcompound.getCompoundTag("altarData");

    NBTTagList allAddedItems =
        altarCompound.getTagList("allAddedItems", Constants.NBT.TAG_COMPOUND);
    NBTTagList currentAddedItems =
        altarCompound.getTagList("currentAddedItems", Constants.NBT.TAG_COMPOUND);

    this.isCrafting = altarCompound.getBoolean("isCrafting");
    this.currentKey = altarCompound.getInteger("currentKey");
    this.currentSpellName = altarCompound.getString("currentSpellName");

    if (altarCompound.hasKey("phylactery")) {
      NBTTagCompound phylactery = altarCompound.getCompoundTag("phylactery");
      if (phylactery != null) this.addedPhylactery = ItemStack.loadItemStackFromNBT(phylactery);
    }

    if (altarCompound.hasKey("catalyst")) {
      NBTTagCompound catalyst = altarCompound.getCompoundTag("catalyst");
      if (catalyst != null) this.addedBindingCatalyst = ItemStack.loadItemStackFromNBT(catalyst);
    }

    this.allAddedItems.clear();
    for (int i = 0; i < allAddedItems.tagCount(); ++i) {
      NBTTagCompound addedItem = (NBTTagCompound) allAddedItems.getCompoundTagAt(i);
      if (addedItem == null) continue;
      ItemStack stack = ItemStack.loadItemStackFromNBT(addedItem);
      if (stack == null) continue;
      this.allAddedItems.add(stack);
    }

    this.currentAddedItems.clear();
    for (int i = 0; i < currentAddedItems.tagCount(); ++i) {
      NBTTagCompound addedItem = (NBTTagCompound) currentAddedItems.getCompoundTagAt(i);
      if (addedItem == null) continue;
      ItemStack stack = ItemStack.loadItemStackFromNBT(addedItem);
      if (stack == null) continue;
      this.currentAddedItems.add(stack);
    }

    this.spellDef.clear();
    for (ArrayList<KeyValuePair<ISpellPart, byte[]>> groups : shapeGroups) groups.clear();

    NBTTagCompound currentSpellDef = altarCompound.getCompoundTag("spellDef");
    this.spellDef.addAll(NBTToISpellPartList(currentSpellDef));

    NBTTagList currentShapeGroups =
        altarCompound.getTagList("shapeGroups", Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < currentShapeGroups.tagCount(); ++i) {
      NBTTagCompound compound = (NBTTagCompound) currentShapeGroups.getCompoundTagAt(i);
      shapeGroups.get(i).addAll(NBTToISpellPartList(compound));
    }
  }
Ejemplo n.º 6
0
  @Override
  public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);

    if (compound.getCompoundTag("DNA") != null)
      stacks[0] = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("DNA"));
    if (compound.getCompoundTag("Egg") != null)
      stacks[1] = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Egg"));

    cultivateTime = compound.getInteger("CultivateTime");
  }
Ejemplo n.º 7
0
  @Override
  public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    storage.readFromNBT(nbt);

    laserSat.readFromNBT(nbt.getCompoundTag("laser"));

    /*NBTTagList tagList = nbt.getTagList("Inventory");
    for (int i = 0; i < tagList.tagCount(); i++) {
    	NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(i);
    	byte slot = tag.getByte("Slot");
    	if (slot >= 0 && slot < invBuffer.length) {
    		invBuffer[slot] = ItemStack.loadItemStackFromNBT(tag);
    	}
    }*/
    if (nbt.hasKey("GlassPane")) {
      NBTTagCompound tag = nbt.getCompoundTag("GlassPane");
      glassPanel = ItemStack.loadItemStackFromNBT(tag);
    }

    laserX = nbt.getInteger("laserX");
    laserZ = nbt.getInteger("laserZ");
    mode = MODE.values()[nbt.getByte("mode")];

    if (mode == MODE.SPIRAL) {
      xCenter = nbt.getInteger("CenterX");
      yCenter = nbt.getInteger("CenterY");
      radius = nbt.getInteger("radius");
      numSteps = nbt.getInteger("numSteps");
      prevDir = ForgeDirection.values()[nbt.getInteger("prevDir")];
    }
  }
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    facing = ForgeDirection.getOrientation(tagCompound.getInteger("direction"));

    isValidMultiblock = tagCompound.getBoolean("isValidMultiblock");

    NBTTagList itemsTag = (NBTTagList) tagCompound.getTag("Items");
    furnaceItems = new ItemStack[getSizeInventory()];

    for (int i = 0; i < itemsTag.tagCount(); i++) {
      NBTTagCompound slotTag = (NBTTagCompound) itemsTag.getCompoundTagAt(i);
      byte slot = slotTag.getByte("Slot");

      if (slot >= 0 && slot < furnaceItems.length)
        furnaceItems[slot] = ItemStack.loadItemStackFromNBT(slotTag);
    }

    furnaceBurnTime = tagCompound.getShort("BurnTime");
    furnaceCookTime = tagCompound.getShort("CookTime");
    currentItemBurnTime = TileEntityFurnace.getItemBurnTime(furnaceItems[1]);
    cooking = tagCompound.getBoolean("active");
    type = tagCompound.getInteger("type");
    if (type == 1) partBlocks = stonebrick;
    hole = hole.readFromNBT(tagCompound, "hole");
  }
  // This is where you load the data that you saved in writeToNBT
  @Override
  public void readFromNBT(NBTTagCompound nbtTagCompound) {
    super.readFromNBT(
        nbtTagCompound); // The super call is required to save and load the tiles location
    final byte NBT_TYPE_COMPOUND = 10; // See NBTBase.createNewByType() for a listing
    NBTTagList dataForAllSlots = nbtTagCompound.getTagList("Items", NBT_TYPE_COMPOUND);

    Arrays.fill(itemStacks, null); // set all slots to empty
    for (int i = 0; i < dataForAllSlots.tagCount(); ++i) {
      NBTTagCompound dataForOneSlot = dataForAllSlots.getCompoundTagAt(i);
      byte slotNumber = dataForOneSlot.getByte("Slot");
      if (slotNumber >= 0 && slotNumber < this.itemStacks.length) {
        this.itemStacks[slotNumber] = ItemStack.loadItemStackFromNBT(dataForOneSlot);
      }
    }

    // Load everything else.  Trim the arrays (or pad with 0) to make sure they have the correct
    // number of elements
    cookTime = nbtTagCompound.getShort("CookTime");
    burnTimeRemaining =
        Arrays.copyOf(nbtTagCompound.getIntArray("burnTimeRemaining"), FUEL_SLOTS_COUNT);
    burnTimeInitialValue =
        Arrays.copyOf(nbtTagCompound.getIntArray("burnTimeInitial"), FUEL_SLOTS_COUNT);
    cachedNumberOfBurningSlots = -1;
  }
Ejemplo n.º 10
0
  @Override
  public void readFromNBT(NBTTagCompound filedata) {
    for (Object obj : filedata.func_150296_c()) {
      if (obj instanceof NBTTagList) {
        NBTTagList entry = (NBTTagList) obj;
        String name = entry.toString(); // TODO See if this is equivilent to 1.6's getName function
        ItemStack[] saveinv = new ItemStack[6];
        if (entry.tagCount() > 0) {
          for (int j = 0; j < entry.tagCount(); j++) {
            NBTTagCompound obj1 = entry.getCompoundTagAt(j);

            if (obj1 instanceof NBTTagCompound) {
              NBTTagCompound dat = (NBTTagCompound) obj1;
              int i = (dat.getByte("Slot")) & 7;
              if (i >= 6) {
                System.out.println("GCInv error retrieving savefile: slot was outside range 0-5");
                return;
              }
              saveinv[i] = ItemStack.loadItemStackFromNBT(dat);
            }
          }
        }
        CommandGCInv.savedata.put(name.toLowerCase(), saveinv);
      }
    }
  }
Ejemplo n.º 11
0
  public ItemStack getItemType() {
    if (getItemCount() == 0) {
      return null;
    }

    return ItemStack.loadItemStackFromNBT(ItemDataUtils.getCompound(bin, "storedItem"));
  }
Ejemplo n.º 12
0
  @Override
  @SideOnly(Side.CLIENT)
  public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean held) {
    if (stack.hasTagCompound() && stack.stackTagCompound.hasKey(IcarusConstants.NBT_ITEMSTACK)) {
      list.add(
          StringHelper.LIGHT_BLUE
              + StringHelper.localize("tooltip.icarus.render.armor")
              + StringHelper.END
              + ": "
              + ItemStack.loadItemStackFromNBT(
                      stack.stackTagCompound.getCompoundTag(IcarusConstants.NBT_ITEMSTACK))
                  .getDisplayName());
    }

    if (!StringHelper.isShiftKeyDown()) {
      IcarusHelper.checkNBT(stack);

      list.add(
          StringHelper.LIGHT_BLUE
              + StringHelper.localize("tooltip.icarus.tier")
              + StringHelper.END
              + ": "
              + (stack.stackTagCompound.getInteger(IcarusConstants.NBT_TIER) + 1));
      if (ConfigHandler.showWingsStats) {
        list.add(IcarusHelper.pressShiftForDetails());
      }
    } else if (StringHelper.isShiftKeyDown()) {
      if (ConfigHandler.showWingsStats) {
        list.addAll(tooltip(stack));
      }
    }
  }
Ejemplo n.º 13
0
  public void readFromItemNBT(NBTTagCompound nbt) {
    temperature = nbt.getInteger("temp");

    NBTTagList nbttaglist = nbt.getTagList("Metals");

    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      int id = nbttagcompound1.getInteger("ID");
      float amount = nbttagcompound1.getShort("Amount");
      // Added so that hopefully old worlds that stored metal as shorts wont break
      float amountF = amount + nbttagcompound1.getFloat("AmountF");
      Metal m = MetalRegistry.instance.getMetalFromItem(Item.itemsList[id]);
      addMetal(MetalRegistry.instance.getMetalFromItem(Item.itemsList[id]), amount);
    }

    nbttaglist = nbt.getTagList("Items");
    storage = new ItemStack[getSizeInventory()];
    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);
      byte byte0 = nbttagcompound1.getByte("Slot");
      if (byte0 >= 0 && byte0 < storage.length) {
        storage[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }

    if (currentAlloy != null) {
      currentAlloy.outputAmount = nbt.getInteger("outputAmount");
    }
  }
Ejemplo n.º 14
0
  @Override
  public void readFromNBT(final NBTTagCompound tag) {
    super.readFromNBT(tag);

    this.age = tag.getLong("age");

    this.inventories.clear();

    final NBTTagCompound inventoriesTag = tag.getCompoundTag("inventories");

    for (final Object key : inventoriesTag.getKeySet()) {
      final String inventoryName = (String) key;
      final NBTTagList inventoryTag = inventoriesTag.getTagList(inventoryName, tag.getId());
      final Map<Integer, ItemStack> inventory = new HashMap<>();

      for (int i = 0; i < inventoryTag.tagCount(); i++) {
        final NBTTagCompound slotTag = inventoryTag.getCompoundTagAt(i);
        final ItemStack stack = ItemStack.loadItemStackFromNBT(slotTag);

        inventory.put((int) slotTag.getByte("slot"), stack);
      }

      this.inventories.put(inventoryName, inventory);
    }

    this.setOwner(NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("owner")));
  }
  @Override
  protected void getBody(ItemStack stack, List<String> currenttip, IWailaDataAccessor accessor) {
    TileEntity te = accessor.getTileEntity();

    if (te instanceof TileAugmentable) {
      if (WailaPlugins.proxy.isShiftKeyDown()) {
        currenttip.add(EnumChatFormatting.AQUA.toString() + "> " + lang.localize("augments.shown"));
        NBTTagList augments =
            accessor.getNBTData().getTagList("augments", Constants.NBT.TAG_COMPOUND);
        for (int i = 0; i < augments.tagCount(); i++) {
          ItemStack augmentStack = ItemStack.loadItemStackFromNBT(augments.getCompoundTagAt(i));
          if (augmentStack != null) {
            IAugmentItem augment = (IAugmentItem) augmentStack.getItem();
            Set<String> descs = augment.getAugmentTypes(augmentStack);
            for (String s : descs) {
              currenttip.add(
                  EnumChatFormatting.WHITE
                      + "-"
                      + SpecialChars.TAB
                      + EnumChatFormatting.WHITE
                      + teLang.localize("augment." + s));
            }
          }
        }
      } else {
        currenttip.add(
            EnumChatFormatting.AQUA.toString()
                + "<"
                + EnumChatFormatting.ITALIC
                + lang.localize("augments.hidden")
                + EnumChatFormatting.AQUA
                + ">");
      }
    }
  }
  @Override
  public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    // ItemStacks
    NBTTagList tagList = tagCompound.getTagList("Items", 10);
    ovenStacks = new ItemStack[getSizeInventory()];

    for (int i = 0; i < tagList.tagCount(); ++i) {
      NBTTagCompound itemTag = tagList.getCompoundTagAt(i);
      byte slot = itemTag.getByte("Slot");

      if (slot >= 0 && slot < ovenStacks.length) {
        ovenStacks[slot] = ItemStack.loadItemStackFromNBT(itemTag);
      }
    }

    // Burn Time & Cook Time
    ovenBurnTime = tagCompound.getShort("BurnTime");
    ovenCookTime = tagCompound.getShort("CookTime");
    currentItemBurnLength = getItemBurnTime(ovenStacks[1]);

    if (tagCompound.hasKey("CustomName")) {
      ovenName = tagCompound.getString("CustomName");
    }
  }
Ejemplo n.º 17
0
  // インベントリの読み込み
  public void load() {
    // ItemStackのNBTを取得、空の中身を作成しておく
    NBTTagCompound nbttagcompound = this.baseChest.getEntityData();
    this.containerItems = new ItemStack[this.getSizeInventory()];

    // NBTが無ければ中身は空のままで
    if (nbttagcompound == null) {
      return;
    }

    NBTTagList nbttaglist = nbttagcompound.getTagList("EquipmentItems", 10);

    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
      int j = nbttagcompound1.getByte("EquipmentSlot") & 0xff;

      if (j >= 0 && j < this.containerItems.length) {
        this.containerItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }

    // EntityLivingのequipmentと同期
    for (int slot = 0; slot < this.containerItems.length; slot++) {
      this.baseChest.setCurrentItemOrArmor(slot, this.containerItems[slot]);
    }
  }
  /** Reads a tile entity from NBT. */
  public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
    super.readFromNBT(par1NBTTagCompound);
    NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    this.chestContents = new ItemStack[this.getSizeInventory()];

    if (par1NBTTagCompound.hasKey("chestID")) {
      this.id = par1NBTTagCompound.getInteger("chestID");
    }

    if (par1NBTTagCompound.hasKey("myAccessTick")) {
      this.accessTicks = par1NBTTagCompound.getInteger("myAccessTick");
    }

    if (par1NBTTagCompound.hasKey("CustomName")) {
      this.customName = par1NBTTagCompound.getString("CustomName");
    }

    for (int i = 0; i < nbttaglist.tagCount(); ++i) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.getCompoundTagAt(i);
      int j = nbttagcompound1.getByte("Slot") & 255;

      if (j >= 0 && j < this.chestContents.length) {
        this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }
  }
Ejemplo n.º 19
0
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
    if (world.isRemote) return;
    if (stack.hasTagCompound()) {
      TileEntity te = world.getTileEntity(x, y, z);
      if (te instanceof TileVendorBlock) {
        TileVendorBlock tentity = (TileVendorBlock) te;
        NBTTagCompound tagCompound = stack.getTagCompound();
        if (tagCompound == null) {
          return;
        }
        NBTTagList tagList = tagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
        for (int i = 0; i < tagList.tagCount(); i++) {
          NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
          byte slot = tag.getByte("Slot");
          if (slot >= 0 && slot < tentity.getSizeInventory()) {
            tentity.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(tag));
          }
        }
        tentity.coinSum = tagCompound.getInteger("CoinSum");
        tentity.userCoinSum = tagCompound.getInteger("UserCoinSum");
        tentity.itemPrice = tagCompound.getInteger("ItemPrice");
        tentity.blockOwner = tagCompound.getString("BlockOwner");
        tentity.infiniteMode = tagCompound.getBoolean("Infinite");
      }
      world.markBlockForUpdate(x, y, z);

    } else {
      // item has no owner so we'll set one and get out of here
      ((TileVendorBlock) world.getTileEntity(x, y, z)).blockOwner = entity.getCommandSenderName();
    }
    int meta = stack.getItemDamage();
    world.setBlockMetadataWithNotify(x, y, z, meta, 2);
  }
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);
    try {
      this.IC_Outputpacketamount = nbttagcompound.getShort("ICOutputpacketamount");
    } catch (Exception e) {
      this.IC_Outputpacketamount = nbttagcompound.getInteger("ICOutputpacketamount");
    }
    this.IC_Output = nbttagcompound.getInteger("ICOutput");
    this.IC_Outputpacketsize = nbttagcompound.getInteger("ICOutputpacketsize");
    this.UE_Output = nbttagcompound.getInteger("UEOutput");
    this.UE_Outputvoltage = nbttagcompound.getInteger("UEOutputvoltage");
    this.UE_Outputamp = nbttagcompound.getInteger("UEOutputamp");

    NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
    this.inventory = new ItemStack[getSizeInventory()];
    for (int i = 0; i < nbttaglist.tagCount(); i++) {
      NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i);

      byte byte0 = nbttagcompound1.getByte("Slot");
      if ((byte0 >= 0) && (byte0 < this.inventory.length)) {
        this.inventory[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
      }
    }
  }
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 @SideOnly(Side.CLIENT)
 public void addInformation(ItemStack stack, EntityPlayer player, List info, boolean par4) {
   NBTTagCompound c = stack.getTagCompound();
   if (getBlockID() == Machine.DeepStorageUnit.getBlockId()
       && stack.getItemDamage() == Machine.DeepStorageUnit.getMeta()
       && c != null) {
     if (c.hasKey("storedStack")) {
       ItemStack storedItem = ItemStack.loadItemStackFromNBT(c.getCompoundTag("storedStack"));
       int storedQuantity = c.getInteger("storedQuantity");
       if (storedItem != null & storedQuantity > 0) {
         info.add(
             "Contains "
                 + storedQuantity
                 + " "
                 + storedItem.getDisplayName()
                 + " ("
                 + storedItem.itemID
                 + ":"
                 + storedItem.getItemDamageForDisplay()
                 + ")");
       } else {
         // info.add("Empty");
       }
     }
   } else if (getBlockID() == Machine.BioFuelGenerator.getBlockId()
       && stack.getItemDamage() == Machine.BioFuelGenerator.getMeta()) {
     info.add("Produces MJ only.");
   }
 }
  @Override
  public ShapedOreRecipe getRecipeFromNBT(NBTTagCompound nbtRecipe) {
    ArrayList<Object> input = new ArrayList<Object>(); // Becomes entire recipe input
    ItemStack output = ItemStack.loadItemStackFromNBT(nbtRecipe.getCompoundTag(NBT_output));

    NBTTagList inputs = nbtRecipe.getTagList(NBT_input);
    for (int i = 0; i < inputs.tagCount(); i++) input.add(((NBTTagString) inputs.tagAt(i)).data);
    NBTTagCompound map = nbtRecipe.getCompoundTag(NBT_map);
    for (NBTBase entry : (Collection<NBTBase>) map.getTags()) {
      input.add(entry.getName().charAt(0));
      if (entry instanceof NBTTagString) input.add(((NBTTagString) entry).data);
      else input.add(ItemStack.loadItemStackFromNBT((NBTTagCompound) entry));
    }

    return new ShapedOreRecipe(output, input.toArray())
        .setMirrored(nbtRecipe.getBoolean(NBT_mirror));
  }
Ejemplo n.º 23
0
  @Override
  protected void readCustomNBT(NBTTagCompound root) {
    if (root.hasKey("accessMode")) {
      accessMode = AccessMode.values()[root.getShort("accessMode")];
    } else {
      // keep behavior the same for blocks placed prior to this update
      accessMode = AccessMode.PUBLIC;
    }
    placedBy = PlayerUtil.getPlayerUIDUnstable(root.getString("placedBy"));
    for (int i = 0; i < password.length; i++) {
      if (root.hasKey("password" + i)) {
        NBTTagCompound stackRoot = (NBTTagCompound) root.getTag("password" + i);
        password[i] = ItemStack.loadItemStackFromNBT(stackRoot);
      } else {
        password[i] = null;
      }
    }
    authorisedUsers.clear();
    String userStr = root.getString("authorisedUsers");
    if (userStr != null && userStr.length() > 0) {
      String[] users = userStr.split(",");
      for (String user : users) {
        if (user != null) {
          user = user.trim();
          if (user.length() > 0) {
            authorisedUsers.add(PlayerUtil.getPlayerUIDUnstable(user));
          }
        }
      }
    }
    if (root.hasKey("itemLabel")) {
      NBTTagCompound stackRoot = (NBTTagCompound) root.getTag("itemLabel");
      itemLabel = ItemStack.loadItemStackFromNBT(stackRoot);
    } else {
      itemLabel = null;
    }

    String sourceBlockStr = root.getString(KEY_SOURCE_BLOCK_ID);
    sourceBlock = Block.getBlockFromName(sourceBlockStr);
    sourceBlockMetadata = root.getInteger(KEY_SOURCE_BLOCK_META);

    label = root.getString("label");
    if (label == null || label.trim().length() == 0) {
      label = null;
    }
  }
Ejemplo n.º 24
0
 @Override
 public void readEntityFromNBT(NBTTagCompound compound) {
   super.readEntityFromNBT(compound);
   if (compound.hasKey("fly_stack")) {
     stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("fly_stack"));
   }
   setFire(compound.getBoolean("flare"));
 }
Ejemplo n.º 25
0
    public void readFromNBT(NBTTagCompound compound) {
      super.readFromNBT(compound);

      if (compound.hasKey("RecordItem", 10)) {
        this.setRecord(ItemStack.loadItemStackFromNBT(compound.getCompoundTag("RecordItem")));
      } else if (compound.getInteger("Record") > 0) {
        this.setRecord(new ItemStack(Item.getItemById(compound.getInteger("Record"))));
      }
    }
Ejemplo n.º 26
0
  @Override
  public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    // LogHelper.debugInfo("read mode = " + ModeProximityTrigger.get(compound.getInteger("mode")));
    mode = ModeProximityTrigger.get(compound.getInteger("mode"));

    if (compound.hasKey("item"))
      stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("item"));
  }
Ejemplo n.º 27
0
 private void readBufferFromNBT(NBTTagCompound tagCompound) {
   NBTTagList bufferTagList = tagCompound.getTagList("Items", Constants.NBT.TAG_COMPOUND);
   for (int i = 0; i < bufferTagList.tagCount(); i++) {
     NBTTagCompound nbtTagCompound = bufferTagList.getCompoundTagAt(i);
     inventoryHelper.setStackInSlot(
         i + ScreenContainer.SLOT_MODULES, ItemStack.loadItemStackFromNBT(nbtTagCompound));
   }
   resetModules();
 }
Ejemplo n.º 28
0
 private void readFromNBT(NBTTagCompound tagCompound) {
   NBTTagList items = tagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
   for (int i = 0; i < items.tagCount(); i++) {
     NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i);
     int slot = item.getInteger("Slot");
     if (slot >= 0 && slot < getSizeInventory())
       inventory[slot] = ItemStack.loadItemStackFromNBT(item);
   }
 }
Ejemplo n.º 29
0
 @Override
 public void readCommonNBT(NBTTagCompound nbt) {
   super.readCommonNBT(nbt);
   if (nbt.hasKey("isRedstonePowerd")) isRedstonePowered = nbt.getBoolean("isRedstonePowerd");
   if (nbt.hasKey("burning")) burning = nbt.getInteger("burning");
   if (nbt.hasKey("burningItem")) {
     NBTTagCompound tag = (NBTTagCompound) nbt.getTag("burningItem");
     burningItem = ItemStack.loadItemStackFromNBT(tag);
   }
 }
 @Override
 public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
   super.readCustomNBT(nbt, descPacket);
   if (nbt.hasKey("identStack")) {
     NBTTagCompound t = nbt.getCompoundTag("identStack");
     this.identStack = ItemStack.loadItemStackFromNBT(t);
   } else this.identStack = null;
   storageAmount = nbt.getInteger("storageAmount");
   lockItem = nbt.getBoolean("lockItem");
 }