/** * @return True if this material is affected by gravity. */ public boolean hasGravity() { if (!isBlock()) { return false; } switch (this) { case SAND: case GRAVEL: case ANVIL: return true; default: return false; } } }
if (!isBlock()) { return false;
if (!isBlock()) { return false;
if (!isBlock()) { return false;
if (!isBlock()) { return false;
if (!isBlock() || id == 0) { return false;
/** * Convenience method to inform the user whether this was a block * placement event. * * @return boolean true if the item in hand was a block */ public boolean isBlockInHand() { if (!hasItem()) { return false; } return item.getType().isBlock(); }
private String name(Statistic stat, Material mat) { if (mat.isBlock()) { checkArgument( stat.getType() == Type.BLOCK, "Statistic " + stat + " is not a block statistic"); } else { checkArgument( stat.getType() == Type.ITEM, "Statistic " + stat + " is not an item statistic"); } return GlowStatistic.getName(stat, mat); }
private void reg(Material material, ItemType type, Sound sound) { if (material.isBlock() != type instanceof BlockType) { throw new IllegalArgumentException( "Cannot mismatch item and block: " + material + ", " + type); } if (materialToType.containsKey(material)) { throw new IllegalArgumentException( "Cannot use " + type + " for " + material + ", is already " + materialToType .get(material)); } materialToType.put(material, type); type.setMaterial(material); if (material.isBlock()) { nextBlockId = Math.max(nextBlockId, material.getId() + 1); ((BlockType) type).setPlaceSound(sound); } else { nextItemId = Math.max(nextItemId, material.getId() + 1); } }
private void reg(Material material, ItemType type) { if (material.isBlock() != type instanceof BlockType) { throw new IllegalArgumentException( "Cannot mismatch item and block: " + material + ", " + type); } if (materialToType.containsKey(material)) { throw new IllegalArgumentException( "Cannot use " + type + " for " + material + ", is already " + materialToType .get(material)); } materialToType.put(material, type); type.setMaterial(material); if (material.isBlock()) { nextBlockId = Math.max(nextBlockId, material.getId() + 1); if (type.getClass() != BlockType.class) { ((BlockType) type).setPlaceSound(Sound.BLOCK_STONE_BREAK); } } else { nextItemId = Math.max(nextItemId, material.getId() + 1); } }
/** * Converts a Material to a BlockType * * @param material The material * @return The blocktype */ public static BlockType asBlockType(Material material) { checkNotNull(material); if (!material.isBlock()) { throw new IllegalArgumentException(material.getKey().toString() + " is not a block!"); } return BlockTypes.get(material.getKey().toString()); }
private ItemType createDefault(Material material) { if (material == null || material == Material.AIR) { return null; } ItemType result; if (material.isBlock()) { result = new BlockType(); } else { result = new ItemType(); } reg(material, result); return result; }
/** * Create a WorldEdit BlockState from a Bukkit ItemStack * * @param itemStack The Bukkit ItemStack * @return The WorldEdit BlockState */ public static BlockState asBlockState(ItemStack itemStack) throws WorldEditException { checkNotNull(itemStack); if (itemStack.getType().isBlock()) { return adapt(itemStack.getType().createBlockData()); } else { throw new NotABlockException(); } }
if (!holding.getType().isBlock()) { return; // Action was already handled by BlockPlacementHandler } else {
checkArgument(((Material) data).isBlock(), "Material is not a block!"); result = ((Material) data).getId(); break;
private static void generateMaterialStatistics() { for (Material material : Material.values()) { String name = ItemIds.getKeyName(material); if (material.isBlock()) { set(MINE_BLOCK, material, "mineBlock.minecraft." + name); } if (material.isItem()) { set(USE_ITEM, material, "useItem.minecraft." + name); set(CRAFT_ITEM, material, "craftItem.minecraft." + name); if (material.getMaxDurability() != 0) { set(BREAK_ITEM, material, "breakItem.minecraft." + name); } } set(DROP, material, "drop.minecraft." + name); set(PICKUP, material, "pickup.minecraft." + name); } }
if (holding.getType().isBlock()) {
public static Set<Material> getAllBlocks(String... names) { final LinkedHashSet<Material> res = new LinkedHashSet<Material>(); for (final String name : names) { final Material mat = get(name); if (mat != null && mat.isBlock()) { res.add(mat); } } return res; }
private static void setFlag(Material material, long addFlag) { if (!material.isBlock()) { // Let's not fail hard here. StaticLog.logWarning("Attempt to set flag for a non-block: " + material); } blockFlags.put(material, blockFlags.get(material) | addFlag); }
public boolean test(Material material) { if (material.isBlock()) { return test(new BlockTarget(BukkitAdapter.asBlockType(material))); } else { return test(new ItemTarget(BukkitAdapter.asItemType(material))); } }