/** * Set the item being consumed * * @param item the item being consumed */ public void setItem(ItemStack item) { if (item == null) { this.item = new ItemStack(Material.AIR); } else { this.item = item; } }
/** * Creates a new ItemStack based on this MaterialData * * @return New ItemStack containing a copy of this MaterialData */ public ItemStack toItemStack() { return new ItemStack(type, 0, data); }
/** * Creates a new ItemStack based on this MaterialData * * @param amount The stack size of the new stack * @return New ItemStack containing a copy of this MaterialData */ public ItemStack toItemStack(int amount) { return new ItemStack(type, amount, data); }
/** * Create a shaped recipe to craft the specified ItemStack. The * constructor merely determines the result and type; to set the actual * recipe, you'll need to call the appropriate methods. * * @param result The item you want the recipe to create. * @see ShapedRecipe#shape(String...) * @see ShapedRecipe#setIngredient(char, Material) * @see ShapedRecipe#setIngredient(char, Material, int) * @see ShapedRecipe#setIngredient(char, MaterialData) */ public ShapedRecipe(ItemStack result) { this.output = new ItemStack(result); }
/** * Sets the input of this furnace recipe. * * @param input The input material. * @param data The data value. (Note: This is currently ignored by the * CraftBukkit server.) * @return The changed recipe, so you can chain calls. * @deprecated Magic value */ @Deprecated public FurnaceRecipe setInput(Material input, int data) { this.ingredient = new ItemStack(input, 1, (short) data); return this; }
@Override public Collection<ItemStack> getDrops(GlowBlock me, ItemStack tool) { // Overridden for cactus to remove data from the dropped item return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.CACTUS))); } }
@Override public Collection<ItemStack> getDrops(GlowBlock me, ItemStack tool) { // Overridden for sugar cane to remove data from the dropped item return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.SUGAR_CANE))); } }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { int rnd = ThreadLocalRandom.current().nextInt(100); if (rnd < 80) { return BlockDropless.EMPTY_STACK; } else { return Collections.unmodifiableList( Arrays.asList(new ItemStack(mushroomType, rnd > 90 ? 2 : 1, data))); } } }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { return Collections.unmodifiableList(Arrays .asList(new ItemStack(Material.MELON, ThreadLocalRandom.current().nextInt(5) + 3))); } }
/** * Converts this potion to an {@link ItemStack} with the specified amount * and a correct damage value. * * @param amount The amount of the ItemStack * @return The created ItemStack */ public ItemStack toItemStack(int amount) { return new ItemStack(Material.POTION, amount, toDamageValue()); }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (tool != null && tool.getType() == Material.SHEARS) { return Arrays.asList(new ItemStack(Material.VINE)); } return BlockDropless.EMPTY_STACK; }
@Override public Collection<ItemStack> getMinedDrops(GlowBlock block) { //TODO use MaterialData instead of magic value if possible byte data = (byte) Math.min(2, block.getData()); return Arrays.asList(new ItemStack(Material.QUARTZ_BLOCK, 1, data)); }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { if (ThreadLocalRandom.current().nextFloat() < .125) { return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.SEEDS, 1))); } return BlockDropless.EMPTY_STACK; }
@Override public Collection<ItemStack> getMinedDrops(GlowBlock block) { ItemStack drop = new ItemStack(Material.ANVIL, 1, (short) (block.getData() / 4)); return Arrays.asList(drop); } }
@Override public void setItemStack(ItemStack stack) { // stone is the "default state" for the item stack according to the client metadata.set(MetadataIndex.ITEM_ITEM, stack == null ? new ItemStack(Material.STONE) : stack.clone()); } }
/** * Create a Bukkit ItemStack from a WorldEdit BaseItemStack * * @param item The WorldEdit BaseItemStack * @return The Bukkit ItemStack */ public static ItemStack adapt(BaseItemStack item) { checkNotNull(item); return new ItemStack(adapt(item.getType()), item.getAmount()); } }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { return Collections.singletonList(new ItemStack(Material.BED, 1, (((GlowBed) block.getState()).getColor().getWoolData()))); }
protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) { BlockFace facing = BlockDispenser.getFacing(block); Vector dispensePosition = BlockDispenser.getDispensePosition(block); ItemStack items = new ItemStack(stack.getType(), 1); stack.setAmount(stack.getAmount() - 1); doDispense(block, items, 6, facing, dispensePosition); return stack.getAmount() > 0 ? stack : null; }
@Override public void pulse() { super.pulse(); if (ticksLived % (20 * 5) == 0 && isObstructed()) { if (EventFactory.getInstance() .callEvent(new HangingBreakEvent(this, RemoveCause.PHYSICS)).isCancelled()) { return; } world.dropItemNaturally(location, new ItemStack(Material.PAINTING)); remove(); } }