/** * Create a furnace recipe to craft the specified ItemStack. * * @param result The item you want the recipe to create. * @param source The input material. */ public FurnaceRecipe(ItemStack result, MaterialData source) { this(result, source.getItemType(), source.getData()); }
@Override public int hashCode() { return ((getItemTypeId() << 8) ^ getData()); }
@Override public String toString() { return getItemType() + "(" + getData() + ")"; }
@Override protected float getSaturation(ItemStack stack) { byte data = stack.getData().getData(); switch (data) { case 0: return 6f; case 1: return 9.6f; default: throw new IllegalArgumentException("Cannot find fish(350) for data: " + data); } }
@Override public final byte getRawData() { return getData().getData(); }
@Override protected int getFoodLevel(ItemStack stack) { byte data = stack.getData().getData(); switch (data) { case 0: case 1: return 2; case 2: case 3: return 1; default: throw new IllegalArgumentException("Cannot find fish(349) for data: " + data); } }
@Override protected int getFoodLevel(ItemStack stack) { byte data = stack.getData().getData(); switch (data) { case 0: return 5; case 1: return 6; default: throw new IllegalArgumentException("Cannot find fish(350) for data: " + data); } } }
/** * Builds a box from one block, and fills it with another. * * @param min the minimum coordinates, relative to this structure's root point * @param max the maximum coordinates, relative to this structure's root point * @param outerType the block type for the faces * @param outerData the block data for the faces * @param innerType the block type for the interior * @param innerData the block data for the interior */ public void fill(Vector min, Vector max, Material outerType, MaterialData outerData, Material innerType, int innerData) { fill(min, max, outerType, outerData.getData(), innerType, innerData); }
@Override protected float getSaturation(ItemStack stack) { byte data = stack.getData().getData(); switch (data) { case 0: case 1: return 0.4f; case 2: case 3: return 0.2f; default: throw new IllegalArgumentException("Cannot find fish(349) for data: " + data); } }
@Override public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException { checkNotNull(data); return spawnFallingBlock(location, data.getItemType(), data.getData()); }
/** * Sets the material that a character in the recipe shape refers to. * * @param key The character that represents the ingredient in the shape. * @param ingredient The ingredient. * @return The changed recipe, so you can chain calls. */ public ShapedRecipe setIngredient(char key, MaterialData ingredient) { return setIngredient(key, ingredient.getItemType(), ingredient.getData()); }
/** * Removes an ingredient from the list. If the ingredient occurs multiple * times, only one instance of it is removed. If the data value is -1, * only ingredients with a -1 data value will be removed. * * @param ingredient The ingredient to remove * @return The changed recipe. */ public ShapelessRecipe removeIngredient(MaterialData ingredient) { return removeIngredient(ingredient.getItemType(), ingredient.getData()); }
/** * Adds multiples of the specified ingredient. * * @param count How many to add (can't be more than 9!) * @param ingredient The ingredient to add. * @return The changed recipe, so you can chain calls. */ public ShapelessRecipe addIngredient(int count, MaterialData ingredient) { return addIngredient(count, ingredient.getItemType(), ingredient.getData()); }
/** * Sets the input of this furnace recipe. * * @param input The input material. * @return The changed recipe, so you can chain calls. */ public FurnaceRecipe setInput(MaterialData input) { return setInput(input.getItemType(), input.getData()); }
/** * Removes multiple instances of an ingredient from the list. If there are * less instances then specified, all will be removed. If the data value * is -1, only ingredients with a -1 data value will be removed. * * @param count The number of copies to remove. * @param ingredient The ingredient to remove. * @return The changed recipe. */ public ShapelessRecipe removeIngredient(int count, MaterialData ingredient) { return removeIngredient(count, ingredient.getItemType(), ingredient.getData()); }
@Override public void setBlock(int x, int y, int z, MaterialData materialData) { setBlock(x, y, z, materialData.getItemTypeId(), materialData.getData()); }
@Override public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) { List<ItemStack> drops = new LinkedList<>(Arrays.asList(new ItemStack(Material.FLOWER_POT))); GlowBlockState state = block.getState(); if (state instanceof GlowFlowerPot) { MaterialData contents = ((GlowFlowerPot) state).getContents(); if (contents != null) { drops.add(new ItemStack(contents.getItemType(), 1, contents.getData())); } } return Collections.unmodifiableList(drops); }
@Override public void saveNbt(CompoundTag tag) { super.saveNbt(tag); if (contents != null) { tag.putString("Item", ItemIds.getName(contents.getItemType())); tag.putInt("Data", contents.getData()); } else { // Mimics how Minecraft does it. tag.putString("Item", ""); tag.putInt("Data", 0); } }
@Override public void save(GlowEnderman entity, CompoundTag tag) { super.save(entity, tag); MaterialData carried = entity.getCarriedMaterial(); // Save the carried block, if there is one. if (carried != null && carried.getItemType() != Material.AIR) { tag.putShort("carried", carried.getItemType().getId()); tag.putShort("carriedData", carried.getData()); } } }