Esempio n. 1
0
  CraftMetaPotion(NBTTagCompound tag) {
    super(tag);

    if (tag.hasKey(POTION_EFFECTS.NBT)) {
      NBTTagList list = tag.getList(POTION_EFFECTS.NBT);
      int length = list.size();
      if (length > 0) {
        customEffects = new ArrayList<PotionEffect>(length);

        for (int i = 0; i < length; i++) {
          NBTTagCompound effect = (NBTTagCompound) list.get(i);
          PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
          int amp = effect.getByte(AMPLIFIER.NBT);
          int duration = effect.getInt(DURATION.NBT);
          boolean ambient = effect.getBoolean(AMBIENT.NBT);
          customEffects.add(new PotionEffect(type, duration, amp, ambient));
        }
      }
    }
  }
Esempio n. 2
0
  CraftMetaBook(NBTTagCompound tag) {
    super(tag);

    if (tag.hasKey(BOOK_TITLE.NBT)) {
      this.title = tag.getString(BOOK_TITLE.NBT);
    }

    if (tag.hasKey(BOOK_AUTHOR.NBT)) {
      this.author = tag.getString(BOOK_AUTHOR.NBT);
    }

    if (tag.hasKey(BOOK_PAGES.NBT)) {
      NBTTagList pages = tag.getList(BOOK_PAGES.NBT);
      String[] pageArray = new String[pages.size()];

      for (int i = 0; i < pages.size(); i++) {
        String page = ((NBTTagString) pages.get(i)).data;
        pageArray[i] = page;
      }

      addPage(pageArray);
    }
  }