/** * 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 String toString() { return getItemType() + "(" + getData() + ")"; }
private boolean isValidContents(MaterialData contents) { if (contents == null) { return false; } switch (contents.getItemType()) { case DEAD_BUSH: case RED_ROSE: case YELLOW_FLOWER: case RED_MUSHROOM: case BROWN_MUSHROOM: case CACTUS: case SAPLING: return true; case LONG_GRASS: // The only allowed tall grass type is the fern. return ((LongGrass) contents).getSpecies() == GrassSpecies.FERN_LIKE; default: return false; } } }
@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 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 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()); } } }
/** * Returns whether the given {@link MaterialData} and the given {@link BlockStateData} are valid * for the given block type and describe the same state. * @param type the block type, or null * @param data the block state that's a {@link MaterialData}, or null * @param state the block state that's a {@link BlockStateData}, or null * @return true if all parameters are non-null, {@code data} is valid for {@code type}, and * {@code state} is empty or matches {@code data}; false otherwise * @throws InvalidBlockStateException if {@code type} is not null but isn't a block type with a * {@link BlockStateReader} */ public static boolean matches(Material type, MaterialData data, BlockStateData state) throws InvalidBlockStateException { if (state == null || data == null || data.getItemType() != type) { return false; } if (state.isEmpty()) { return true; } BlockStateReader reader = getReader(type); if (reader == null) { return false; } return reader.matches(state, data); }
chunkData.setBlock(x, y, z, groundMat); if (deep == 0 && groundMat.getItemType() == Material.SAND) { deep = random.nextInt(4) + Math.max(0, y - seaLevel - 1); groundMat = SANDSTONE;
@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); } }
players .filter(player -> player.getItemInHand() != null) .filter(player -> player.getItemInHand().getData().getItemType() != Material.AIR) .filter(player -> enchantment.canEnchantItem(player.getItemInHand())) .forEach(player -> {
} else if (data instanceof WoodenStep) { ((WoodenStep) data).setInverted(true); } else if (data.getItemType() == Material.STONE_SLAB2 || data.getItemType() == Material.PURPUR_SLAB) { Step slab = new Step(data.getItemType()); slab.setInverted(true); data = slab;
Material mat = materialData.getItemType();
/** * 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()); }
/** * 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()); }
/** * 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()); }