/** * An item stack with no extra data * * @param type item material * @param amount stack size */ public ItemStack(final Material type, final int amount) { this(type.getId(), amount); }
/** * An item stack with the specified damage / durabiltiy * * @param type item material * @param amount stack size * @param damage durability / damage */ public ItemStack(final Material type, final int amount, final short damage) { this(type.getId(), amount, damage); }
@Override public int getBlockId() { return material.getId(); }
/** * * @deprecated Magic value */ @Deprecated public MaterialData(final Material type, final byte data) { this(type.getId(), data); }
/** * @deprecated this method uses an ambiguous data byte object */ @Deprecated public ItemStack(final Material type, final int amount, final short damage, final Byte data) { this(type.getId(), amount, damage, data); }
/** * Get the id assigned to this ItemType. * * @return The corresponding id. * @deprecated Magic value */ @Deprecated public final int getId() { return material == null ? id : material.getId(); }
/** * Get the full string identifier for a specified Material. * * @param mat the Material. * @return the identifier. */ public static String getName(Material mat) { checkNotNull(mat, "Material cannot be null"); // NON-NLS return names.get(mat.getId()); }
/** * Set the Material type of a block with data and optionally apply physics. * * @param type The type to set the block to. * @param data The raw data to set the block to. * @param applyPhysics notify this block and surrounding blocks to update physics */ public void setType(Material type, byte data, boolean applyPhysics) { setTypeIdAndData(type.getId(), data, applyPhysics); }
@Override public void setBlock(int x, int y, int z, Material material) { setBlock(x, y, z, material.getId()); }
/** * Set the Material type of a block and optionally apply physics. */ @Override public void setType(Material type, boolean applyPhysics) { setTypeId(type.getId(), applyPhysics); }
@Override public final void setType(Material type) { setTypeId(type.getId()); }
@Override public HashMap<Integer, ItemStack> all(Material material) { return all(material.getId()); }
@Override public void setType(Material type) { setTypeId(type.getId()); }
@Override public int first(Material material) { return first(material != null ? material.getId() : 0); }
/** * Sets the type of this item * <p> * Note that in doing so you will reset the MaterialData for this stack * * @param type New type to set the items in this stack to */ @Utility public void setType(Material type) { Validate.notNull(type, "Material cannot be null"); setTypeId(type.getId()); }
@Override public boolean breakNaturally(ItemStack tool) { Collection<ItemStack> drops = getDrops(tool); if (!drops.isEmpty()) { return breakNaturally(1.0f, drops); } else { return setTypeId(Material.AIR.getId()); } }
@Override public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against) { return block.getWorld().getBlockTypeIdAt(block.getX(), block.getY() - 1, block.getZ()) == Material.SOUL_SAND.getId(); }
@Override public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against) { return block.getWorld().getBlockTypeIdAt(block.getX(), block.getY() - 1, block.getZ()) != Material.AIR.getId(); } }
@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()); } } }