Пример #1
0
 public void burn() {
   // Can't burn? Goodbye
   if (!canBurn()) {
     return;
   }
   ItemStack itemstack = getBurnResult(contents[0]);
   // Nothing in there? Then put something there.
   if (contents[2] == null) {
     contents[2] = itemstack.cloneItemStack();
   }
   // Burn ahead
   else if (contents[2].doMaterialsMatch(itemstack)) {
     contents[2].count += itemstack.count;
   }
   // And consume the ingredient item
   // Goddamn, you have container functions, use them! Notch!
   if (contents[0].getItem().u()) // Derpnote
   {
     contents[0] = new ItemStack(contents[0].getItem().t()); // Derpnote
   } else {
     contents[0].count--;
     // Let 0 be null
     if (contents[0].count <= 0) {
       contents[0] = null;
     }
   }
 }
Пример #2
0
  @Override
  public ItemStack setBook(Tag item) {
    ItemStack chestItem = new ItemStack(Material.WRITTEN_BOOK);
    // Bukkit.getLogger().info("item data");
    // Bukkit.getLogger().info(item.toString());

    Map<String, Tag> contents =
        (Map<String, Tag>) ((CompoundTag) item).getValue().get("tag").getValue();
    // BookMeta bookMeta = (BookMeta) chestItem.getItemMeta();
    String author = ((StringTag) contents.get("author")).getValue();
    // Bukkit.getLogger().info("Author: " + author);
    // bookMeta.setAuthor(author);
    String title = ((StringTag) contents.get("title")).getValue();
    // Bukkit.getLogger().info("Title: " + title);
    // bookMeta.setTitle(title);

    Map<String, Tag> display = (Map<String, Tag>) (contents.get("display")).getValue();
    List<Tag> loreTag = ((ListTag) display.get("Lore")).getValue();
    List<String> lore = new ArrayList<String>();
    for (Tag s : loreTag) {
      lore.add(((StringTag) s).getValue());
    }
    // Bukkit.getLogger().info("Lore: " + lore);
    net.minecraft.server.v1_7_R4.ItemStack stack = CraftItemStack.asNMSCopy(chestItem);
    // Pages
    NBTTagCompound tag = new NBTTagCompound(); // Create the NMS Stack's NBT (item data)
    tag.setString("title", title); // Set the book's title
    tag.setString("author", author);
    NBTTagList pages = new NBTTagList();
    List<Tag> pagesTag = ((ListTag) contents.get("pages")).getValue();
    for (Tag s : pagesTag) {
      pages.add(new NBTTagString(((StringTag) s).getValue()));
    }
    tag.set("pages", pages); // Add the pages to the tag
    stack.setTag(tag); // Apply the tag to the item
    chestItem = CraftItemStack.asCraftMirror(stack);
    ItemMeta bookMeta = (ItemMeta) chestItem.getItemMeta();
    bookMeta.setLore(lore);
    chestItem.setItemMeta(bookMeta);
    return chestItem;
  }
Пример #3
0
 private int getFuelTime(ItemStack item) {
   if (item == null) {
     return 0;
   }
   // CUSTOM FUEL HERE
   // Lava should melt 128 items, not 100
   if (Item.getId(item.getItem()) == org.bukkit.Material.LAVA_BUCKET.getId()) {
     return 25600;
   } else {
     return fuelTime(item);
   }
 }
Пример #4
0
 public void setItem(int i, ItemStack itemstack) {
   contents[i] = itemstack;
   if (itemstack != null && itemstack.count > getMaxStackSize()) {
     itemstack.count = getMaxStackSize();
   }
 }