Example #1
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"));
        }
      }
    }
Example #2
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)));
      }
    }
  }
Example #4
0
  public ItemStack getCraftingResult() {
    this.cost = 0;
    ItemStack output = this.tool.getStack().copy();

    NBTTagList toolList = getEnchantmentTagList(output);
    NBTTagList bookList = getEnchantmentTagList(this.enchantedBook.copy());

    boolean changed = false;

    for (int iBook = 0; iBook < bookList.tagCount(); iBook++) {
      boolean found = false;
      NBTTagCompound bookEnchant = bookList.getCompoundTagAt(iBook);

      // Check the tool for allowed enchants
      if (!this.tool
          .getItem()
          .getAllowedEnchantments()
          .contains(Enchantment.enchantmentsList[bookEnchant.getShort("id")].type)) continue;

      // Check if the enchant already exists
      for (int iTool = 0; iTool < toolList.tagCount(); iTool++) {
        NBTTagCompound toolEnchant = toolList.getCompoundTagAt(iTool);
        if (toolEnchant.getShort("id") == bookEnchant.getShort("id")) {
          found = true;
          if (toolEnchant.getShort("lvl") < bookEnchant.getShort("lvl")) {
            changed = true;
            toolEnchant.setShort("lvl", bookEnchant.getShort("lvl"));
          }
          continue;
        }
      }

      // It doesn't exist yet, just add it
      if (!found) {
        boolean allowed = true;
        for (int iTool = 0; iTool < toolList.tagCount(); iTool++) {
          int toolEnchant = toolList.getCompoundTagAt(iTool).getShort("id");
          if (!Enchantment.enchantmentsList[toolEnchant].canApplyTogether(
              Enchantment.enchantmentsList[bookEnchant.getShort("id")])) {
            allowed = false;
          }
        }

        if (allowed) {
          changed = true;
          toolList.appendTag(bookEnchant);
          int lvl = bookEnchant.getShort("lvl") + 1;
          int cost = lvl * lvl * 2 / (this.tool.getHeadMaterial().arcaneLevel + 1);
          this.cost += cost;
        }
      }
    }

    if ((output.getEnchantmentTagList() == null || output.getEnchantmentTagList().tagCount() == 0)
        && toolList.tagCount() > 0) {
      output.getTagCompound().setTag("ench", toolList);
    }

    return changed ? output : null;
  }
  @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));
    }
  }
  @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;
  }
Example #8
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();
  }
Example #9
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);
      }
    }
  }
  /** 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 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");
    }
  }
  @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
  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
                + ">");
      }
    }
  }
Example #14
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]);
    }
  }
  /** (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();
  }
Example #16
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")));
  }
Example #17
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;
  }
  @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);
    }
  }
Example #19
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();
 }
 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);
   }
 }
 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);
   }
 }
Example #22
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);
   }
 }
Example #23
0
 @Override
 public void readFromNBT(NBTTagCompound tag) {
   NBTTagList list = tag.getTagList("PlayerData", 10);
   for (int i = 0; i < list.tagCount(); i++) {
     NBTTagCompound playerData = list.getCompoundTagAt(i);
     UUID uuid = new UUID(playerData.getLong("UUIDMost"), playerData.getLong("UUIDLeast"));
     PlayerData data = new PlayerData(playerData);
     savedData.put(uuid, data);
   }
 }
  private void findBestEquipment() {

    int bestScore = -1;
    ItemStack bestWeapon = null;
    int bestLocation = 0;
    ItemStack currentCheck;
    int currentScore;
    for (int i = 0; i < this.inventory.mainInventory.length; i++) {
      currentCheck = this.inventory.mainInventory[i];
      if (currentCheck == null) continue;
      Multimap map = currentCheck.getAttributeModifiers();
      Collection Attributes =
          (Collection) map.get(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName());

      if (Attributes.size() == 0) currentScore = 0;
      else currentScore = (int) ((AttributeModifier) Attributes.toArray()[0]).getAmount();
      NBTTagList enchList = currentCheck.getEnchantmentTagList();
      if (enchList == null) currentScore += 0;
      else {
        for (int j = 0; j < enchList.tagCount(); j++) {
          NBTTagCompound comp = (NBTTagCompound) enchList.getCompoundTagAt(j);
          int enchId = comp.getShort("id");
          int enchLvl = comp.getShort("lvl");
          switch (enchId) {
            case 16:
              currentScore += (1 * enchLvl);
              break;
            case 19:
              currentScore += (1 * enchLvl);
              break;
            case 20:
              currentScore += (2 * enchLvl);
              break;
            default:
              currentScore += 1;
          }
        }
      }
      UnDeath.logging.info(
          String.format("Item %s got score %d", currentCheck.toString(), currentScore));
      if (currentScore > bestScore) {
        bestWeapon = currentCheck;
        bestLocation = i;
        bestScore = currentScore;
      }
    }
    if (bestScore == -1) {
      UnDeath.logging.info("No weapons found");
      this.inventory.currentItem = -1;
      return;
    }
    UnDeath.logging.info(
        String.format("Best Weapon is %s with score %d", bestWeapon.toString(), bestScore));
    this.inventory.currentItem = bestLocation;
  }
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    this.owner = nbttagcompound.getString("owner").replace(".", "");
    this.spaceStationName = nbttagcompound.getString("spaceStationName");

    if (nbttagcompound.hasKey("dataCompound")) {
      this.dataCompound = nbttagcompound.getCompoundTag("dataCompound");
    } else {
      this.dataCompound = new NBTTagCompound();
    }

    if (nbttagcompound.hasKey("homePlanet")) {
      this.homePlanet = nbttagcompound.getInteger("homePlanet");
    } else {
      GCLog.info(
          "Home planet data not found in space station save file for \""
              + this.spaceStationName
              + "\". Using default overworld.");
      this.homePlanet = 0; // Overworld dimension ID
    }

    if (nbttagcompound.hasKey("dimensionIdStatic")) {
      this.dimensionIdStatic = nbttagcompound.getInteger("dimensionIdStatic");
    } else {
      GCLog.info(
          "Static dimension ID not found in space station save file for \""
              + this.spaceStationName
              + "\". Using default overworld.");
      this.dimensionIdStatic = ConfigManagerCore.idDimensionOverworldOrbitStatic;
    }

    if (nbttagcompound.hasKey("dimensionIdDynamic")) {
      this.dimensionIdDynamic = nbttagcompound.getInteger("dimensionIdDynamic");
    } else {
      GCLog.info(
          "Dynamic dimension ID not found in space station save file for \""
              + this.spaceStationName
              + "\". Using default overworld.");
      this.dimensionIdDynamic = ConfigManagerCore.idDimensionOverworldOrbit;
    }

    this.allowAllPlayers = nbttagcompound.getBoolean("allowedAll");

    final NBTTagList var2 = nbttagcompound.getTagList("allowedPlayers", 10);
    this.allowedPlayers.clear();

    for (int var3 = 0; var3 < var2.tagCount(); ++var3) {
      final NBTTagCompound var4 = var2.getCompoundTagAt(var3);
      final String var5 = var4.getString("allowedPlayer");

      if (!this.allowedPlayers.contains(var5)) {
        this.allowedPlayers.add(var5);
      }
    }
  }
Example #26
0
  @Override
  protected void readEntityFromNBT(NBTTagCompound nbt) {
    age = nbt.getShort("Age");
    items = Lists.newArrayList();

    NBTTagList list = nbt.getTagList("Items", 10);
    for (int i = 0; i < list.tagCount(); i++) {
      NBTTagCompound listTag = list.getCompoundTagAt(i);
      items.add(ItemStack.loadItemStackFromNBT(listTag));
    }
  }
  @Override
  protected void readEntityFromNBT(NBTTagCompound tag) {
    if (fire != null) fire.clear();
    else fire = new ArrayList<BlockCoord>();

    NBTTagList fires = tag.getTagList("blockCoords", Constants.NBT.TAG_COMPOUND);

    for (int i = 0; i < fires.tagCount(); i++) {
      fire.add(BlockCoord.readFromNBT(fires.getCompoundTagAt(i)));
    }
  }
 @Override
 public void readFromNBT(NBTTagCompound nbt) {
   super.readFromNBT(nbt);
   if (nbt.hasKey("Items")) {
     NBTTagList l = (NBTTagList) nbt.getTag("Items");
     for (int i = 0; i < l.tagCount(); i++) {
       NBTTagCompound item = l.getCompoundTagAt(i);
       slots[item.getInteger("Slot")] = ItemStack.loadItemStackFromNBT(item);
     }
   }
 }
 public void fromNbt(NBTTagCompound tag) {
   clear();
   NBTTagList elements = tag.getTagList("elements", Constants.NBT.TAG_COMPOUND);
   for (int i = 0; i < elements.tagCount(); ++i) {
     NBTTagCompound element = elements.getCompoundTagAt(i);
     Key k = Key.fromNbt(element.getCompoundTag("key"));
     Integer count = element.getInteger("count");
     _elements.put(k, count);
   }
   _size = tag.getInteger("size");
 }
  public void readFromNBT(NBTTagCompound nbt) {
    NBTTagList tagList = nbt.getTagList(ItemMagnet.TAG_BLACKLISTINVENTORY, NBT.TAG_COMPOUND);

    for (int i = 0; i < tagList.tagCount(); i++) {
      NBTTagCompound compound = tagList.getCompoundTagAt(i);
      int slot = compound.getInteger("slot");

      if (slot >= 0 && slot < getSizeInventory()) {
        inventory[slot] = ItemStack.loadItemStackFromNBT(compound);
      }
    }
  }