예제 #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 nbtTags) {
    super.readFromNBT(nbtTags);

    finishedCalc = nbtTags.getBoolean("finishedCalc");

    if (nbtTags.hasKey("fluidTank")) {
      fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
    }

    if (nbtTags.hasKey("activeNodes")) {
      NBTTagList tagList = nbtTags.getTagList("activeNodes", NBT.TAG_COMPOUND);

      for (int i = 0; i < tagList.tagCount(); i++) {
        activeNodes.add(Coord4D.read((NBTTagCompound) tagList.getCompoundTagAt(i)));
      }
    }

    if (nbtTags.hasKey("usedNodes")) {
      NBTTagList tagList = nbtTags.getTagList("usedNodes", NBT.TAG_COMPOUND);

      for (int i = 0; i < tagList.tagCount(); i++) {
        usedNodes.add(Coord4D.read((NBTTagCompound) tagList.getCompoundTagAt(i)));
      }
    }
  }
예제 #3
0
  /// Initializes the entity's stats.
  @Override
  public void init(MobStatsInfo mobStats) {
    NBTTagCompound tag = new NBTTagCompound();
    mobStats.theEntity.writeToNBT(tag);

    NBTTagList tagList = tag.getTagList("Pos", Constants.NBT.TAG_DOUBLE);
    double x = tagList.func_150309_d(0);
    double y = tagList.func_150309_d(1);
    double z = tagList.func_150309_d(2);
    tagList.func_150304_a(0, new NBTTagDouble(0.0));
    tagList.func_150304_a(1, new NBTTagDouble(0.0));
    tagList.func_150304_a(2, new NBTTagDouble(0.0));

    tagList = tag.getTagList("Rotation", Constants.NBT.TAG_FLOAT);
    float yaw = tagList.func_150308_e(0);
    tagList.func_150304_a(0, new NBTTagFloat(0.0F));

    this.nbtStats.generate(mobStats.theEntity, tag, mobStats);

    tagList = tag.getTagList("Pos", Constants.NBT.TAG_DOUBLE);
    tagList.func_150304_a(0, new NBTTagDouble(tagList.func_150309_d(0) + x));
    tagList.func_150304_a(1, new NBTTagDouble(tagList.func_150309_d(1) + y));
    tagList.func_150304_a(2, new NBTTagDouble(tagList.func_150309_d(2) + z));

    tagList = tag.getTagList("Rotation", Constants.NBT.TAG_FLOAT);
    tagList.func_150304_a(0, new NBTTagFloat(tagList.func_150308_e(0) + yaw));

    mobStats.theEntity.readFromNBT(tag);
  }
예제 #4
0
    @Override
    public void readFromNBT(NBTTagCompound tagCom) {
      TEC.idToUsername.clear();
      NBTTagList idUsernameTag = tagCom.getTagList("idUsernames", 10);
      for (int i = 0; i < idUsernameTag.tagCount(); i++) {
        NBTTagCompound tag = idUsernameTag.getCompoundTagAt(i);
        TEC.idToUsername.put(
            UUID.fromString(tagCom.getString("UUID")), tagCom.getString("playerName"));
      }

      TEC.aspectBuffer.clear();
      NBTTagList bufferTag = tagCom.getTagList("bufferTag", 10);
      for (int i = 0; i < bufferTag.tagCount(); i++) {
        NBTTagCompound idedBuffer = bufferTag.getCompoundTagAt(i);
        UUID playerID = UUID.fromString(idedBuffer.getString("playerID"));
        NBTTagList playersBuffer = idedBuffer.getTagList("buffer", 10);
        for (int j = 0; j < playersBuffer.tagCount(); j++) {
          NBTTagCompound bufferEntry = playersBuffer.getCompoundTagAt(j);

          NBTTagCompound scanTag = bufferEntry.getCompoundTag("scan");
          ScanResult scan =
              new ScanResult(
                  scanTag.getByte("type"),
                  scanTag.getInteger("id"),
                  scanTag.getInteger("meta"),
                  EntityList.createEntityFromNBT(
                      scanTag.getCompoundTag("entityTag"), DimensionManager.getWorld(0)),
                  scanTag.getString("phenomena"));

          TEC.addAspect(
              playerID, scan, bufferEntry.getDouble("chance"), bufferEntry.getDouble("percent"));
        }
      }
    }
예제 #5
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");
    }
  }
  @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));
    }
  }
예제 #7
0
  private static Object[][] readRecipe(NBTBase tag) {
    if (!(tag instanceof NBTTagCompound)) {
      return null;
    }

    NBTTagCompound tagCompound = (NBTTagCompound) tag;

    return new Object[][] {
      readItems(tagCompound.getTagList("input")), readItems(tagCompound.getTagList("output")),
    };
  }
  @Override
  public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
    super.readCustomNBT(nbt, descPacket);
    facing = nbt.getInteger("facing");
    energyStorage.readFromNBT(nbt);

    tank.readFromNBT(nbt.getCompoundTag("tank"));

    this.inventory = Utils.readInventory(nbt.getTagList("inventory", 10), 5);
    this.predictedOutput = Utils.readInventory(nbt.getTagList("predictedOutput", 10), 5);
    process = nbt.getIntArray("process");
  }
예제 #9
0
 public void readFromNBT(NBTTagCompound tag) {
   NBTTagList li = tag.getTagList("locs", NBTTypes.COMPOUND.ID);
   for (Object o : li.tagList) {
     NBTTagCompound entry = (NBTTagCompound) o;
     WorldLocation src = WorldLocation.readFromNBT(entry);
     NBTTagList map = tag.getTagList("map", NBTTypes.COMPOUND.ID);
     for (Object o2 : li.tagList) {
       NBTTagCompound nbt = (NBTTagCompound) o2;
       WorldLocation tg = WorldLocation.readFromNBT(nbt);
       this.addLink(src, tg);
     }
   }
 }
예제 #10
0
  private static Object[][][] readTag(NBTTagCompound tag, String key) {
    if (!tag.hasKey(key) || tag.getTagList(key).tagCount() < 1) {
      return null;
    }

    NBTTagList tagList = tag.getTagList(key);
    int length = tagList.tagCount();
    Object[][][] recipes = new Object[length][][];

    for (int i = 0; i < length; i++) {
      recipes[i] = readRecipe(tagList.tagAt(i));
    }

    return recipes;
  }
 @Override
 public void readFromNBT(NBTTagCompound compound) {
   super.readFromNBT(compound);
   if (compound.hasKey("CustomName")) customTitle = compound.getString("CustomName");
   if (contents != null) NbtUtils.readItems(contents, compound.getTagList("Items"));
   if (compound.getBoolean("ComparatorAccessed")) compAccessedOnLoad = true;
 }
  @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;
        }
      }
    }
  }
  // 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;
  }
예제 #14
0
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    inv.readFromNBT(nbttagcompound);

    if (nbttagcompound.hasKey("box")) {
      box.initialize(nbttagcompound.getCompoundTag("box"));
    }

    if (nbttagcompound.hasKey("path")) {
      path = new LinkedList<BlockIndex>();
      NBTTagList list = nbttagcompound.getTagList("path", Constants.NBT.TAG_COMPOUND);

      for (int i = 0; i < list.tagCount(); ++i) {
        path.add(new BlockIndex(list.getCompoundTagAt(i)));
      }
    }

    done = nbttagcompound.getBoolean("done");
    fluidTank.readFromNBT(nbttagcompound);

    // The rest of load has to be done upon initialize.
    initNBT = (NBTTagCompound) nbttagcompound.getCompoundTag("bptBuilder").copy();
  }
예제 #15
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
  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);
      }
    }
  }
  @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");
    }
  }
예제 #18
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);
      }
    }
  }
  @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);
  }
  /** (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();
  }
예제 #22
0
 public static List<Text> getPagesFromNBT(NBTTagCompound compound) {
   final NBTTagList list = compound.getTagList(ITEM_BOOK_PAGES, TAG_STRING);
   if (list.hasNoTags()) {
     return new ArrayList<>();
   }
   return SpongeTexts.fromLegacy(list);
 }
 @Override
 public void readFromNBT(NBTTagCompound compound) {
   NBTTagList tagList = compound.getTagList("portalLandings", Constants.NBT.TAG_STRING);
   for (int i = 0; i < tagList.tagCount(); i++) {
     String s = tagList.getStringTagAt(i);
     portalLandingList.add(i, s);
   }
 }
예제 #24
0
  @Override
  public void spawnServerSide(
      EntityPlayerMP player, NBTTagCompound dataFromClient, NBTTagCompound rewardData) {
    byte baseRotation =
        dataFromClient.getBoolean(ROTATE_KEY) ? dataFromClient.getByte(BASEROTATION_KEY) : -1;
    NBTTagList list = dataFromClient.getTagList(SHAPES_KEY, COMPOUND);
    for (int i = 0; i < list.tagCount(); i++) {
      NBTTagCompound shapeNbt = list.getCompoundTagAt(i);

      ArrayList<NBTTagCompound> blockDataList = new ArrayList<>();
      NBTTagList blockDataNbt = shapeNbt.getTagList(BLOCKDATA_KEY, COMPOUND);
      for (int j = 0; j < blockDataNbt.tagCount(); j++)
        blockDataList.add(blockDataNbt.getCompoundTagAt(j));

      applyShape(Shapes.loadShape(shapeNbt), player, blockDataList, baseRotation);
    }
  }
  /*
  public Collection<CastingRecipe> getRecipesPerformed(EntityPlayer ep) {
  	Collection<CastingRecipe> c = new HashSet();
  	NBTTagList li = this.getNBTRecipes(ep);
  	for (Object o : li.tagList) {
  		NBTTagCompound tag = (NBTTagCompound)o;
  		ItemStack is = ItemStack.loadItemStackFromNBT(tag);
  		c.addAll(RecipesCastingTable.instance.getAllRecipesMaking(is));
  	}
  	return c;
  }

  private NBTTagList getNBTRecipes(EntityPlayer ep) {
  	String key = "recipes";
  	NBTTagCompound tag = this.getNBT(ep);
  	if (!tag.hasKey(key))
  		tag.setTag(key, new NBTTagList());
  	NBTTagList li = tag.getTagList(key, NBTTypes.COMPOUND.ID);
  	tag.setTag(key, li);
  	return li;
  }

  public boolean givePlayerRecipe(EntityPlayer ep, CastingRecipe cr) {
  	if (!this.playerHasRecipe(ep, cr)) {
  		NBTTagCompound tag = new NBTTagCompound();
  		cr.getOutput().writeToNBT(tag);
  		this.getNBTRecipes(ep).appendTag(tag);
  		if (ep instanceof EntityPlayerMP)
  			ReikaPlayerAPI.syncCustomData((EntityPlayerMP)ep);
  		this.notifyPlayerOfProgression(ep, cr);
  		return true;
  	}
  	return false;
  }

  public boolean playerHasRecipe(EntityPlayer ep, CastingRecipe cr) {
  	return this.getRecipesPerformed(ep).contains(cr);
  }
   */
  private NBTTagList getNBTFragments(EntityPlayer ep) {
    String key = "fragments";
    NBTTagCompound tag = this.getNBT(ep);
    if (!tag.hasKey(key)) tag.setTag(key, new NBTTagList());
    NBTTagList li = tag.getTagList(key, NBTTypes.STRING.ID);
    tag.setTag(key, li);
    return li;
  }
 private NBTTagList getNBTRecipes(EntityPlayer ep) {
   String key = "recipes";
   NBTTagCompound tag = this.getNBT(ep);
   if (!tag.hasKey(key)) tag.setTag(key, new NBTTagList());
   NBTTagList li = tag.getTagList(key, NBTTypes.INT.ID);
   tag.setTag(key, li);
   return li;
 }
예제 #27
0
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   NBTTagList entryList = tag.getTagList("entryList", Constants.NBT.TAG_COMPOUND);
   FactionEntry entry;
   for (int i = 0; i < entryList.tagCount(); i++) {
     entry = new FactionEntry(entryList.getCompoundTagAt(i));
     playerFactionEntries.put(entry.playerName, entry);
   }
 }
예제 #28
0
 public void readFromNBT(NBTTagCompound nbt) {
   NBTTagList list = nbt.getTagList("GatheringLocations", 10);
   for (int i = 0; i < list.tagCount(); i++) {
     NBTTagCompound tag = list.getCompoundTagAt(i);
     GatheringLocation location = new GatheringLocation();
     location.readFromNBT(tag);
     locations.add(location);
   }
 }
예제 #29
0
 @Override
 public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) {
   super.readEntityFromNBT(par1NBTTagCompound);
   NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND);
   this.inventory.readFromNBT(nbttaglist);
   this.inventory.currentItem = par1NBTTagCompound.getInteger("SelectedItemSlot");
   this.setPigZombieName(par1NBTTagCompound.getString("zombieName"));
   this.dropItems = par1NBTTagCompound.getBoolean("dropItems");
 }
  public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    NBTTagList var2 = compound.getTagList("Items");
    NBTTagList research = compound.getTagList("Research");

    this.progress = (int) compound.getShort("Progress");

    this.inventory = new ItemStack[this.getSizeInventory()];

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

      if (var5 >= 0 && var5 < this.inventory.length) {
        this.inventory[var5] = ItemStack.loadItemStackFromNBT(var4);
      }
    }
  }