@Override public void populate(World world, Random random, Chunk chunk) { int sourceX = chunk.getX() << 4; int sourceZ = chunk.getZ() << 4; for (int i = 0; i < random.nextInt(6) + 3; i++) { int x = sourceX + random.nextInt(16); int z = sourceZ + random.nextInt(16); int y = random.nextInt(28) + 4; if (world.getBlockAt(x, y, z).getType() == Material.STONE) { world.getBlockAt(x, y, z).setType(Material.EMERALD_ORE); } } } }
/** * Generates up to 64 flowers around the given point. */ @Override public boolean generate(World world, Random random, int sourceX, int sourceY, int sourceZ) { boolean succeeded = false; for (int i = 0; i < 64; i++) { int x = sourceX + random.nextInt(8) - random.nextInt(8); int z = sourceZ + random.nextInt(8) - random.nextInt(8); int y = sourceY + random.nextInt(4) - random.nextInt(4); Block block = world.getBlockAt(x, y, z); if (y < 255 && block.getType() == Material.AIR && block.getRelative(BlockFace.DOWN).getType() == Material.GRASS) { block.setType(type); block.setData((byte) data); succeeded = true; } } return succeeded; } }
if (Arrays.asList(MATERIALS).contains(block.getType()) || block.getType() == Material.PACKED_ICE) { block.setType(Material.PACKED_ICE); stackHeight--; if (stackHeight <= 0) { .getBlockAt(sourceX + x, sourceY + tipOffset + y, sourceZ + z); if (Arrays.asList(MATERIALS).contains(block.getType())) { block.setType(Material.PACKED_ICE); succeeded = true; .getBlockAt(sourceX + x, sourceY + tipOffset - y, sourceZ + z); if (Arrays.asList(MATERIALS).contains(block.getType())) { block.setType(Material.PACKED_ICE); succeeded = true;
/** * Removes the grass, shrub, flower or mushroom directly above the given block, if present. Does * not drop an item. * * @param block the block to update * @return true if a plant was removed; false if none was present */ static boolean killPlantAbove(Block block) { Block blockAbove = block.getRelative(BlockFace.UP); Material mat = blockAbove.getType(); if (PLANT_TYPES.contains(mat)) { if (mat == Material.DOUBLE_PLANT) { MaterialData dataAbove = blockAbove.getState().getData(); if (dataAbove instanceof DoublePlant && ((DoublePlant) dataAbove).getSpecies() == DoublePlantSpecies.PLANT_APEX) { blockAbove.getRelative(BlockFace.UP) .setType(Material.AIR); } } blockAbove.setType(Material.AIR); return true; } return false; }
@Override public void pulse() { super.pulse(); // "While in the End, [..] will continually generate fire, [..] replacing any other block" if (world.getEnvironment() == Environment.THE_END) { Block block = location.getBlock(); if (block.getType() != Material.FIRE) { block.setType(Material.FIRE); } } }
/** * Test whether this pattern matches a block. * @param location the base location * @param clear if true, change the matching blocks for one alignment to air * @param xz TODO: document this parameter * @param y TODO: document this parameter * @return true if this pattern matches; false otherwise */ public boolean matches(Location location, boolean clear, int xz, int y) { for (Alignment alignment : Alignment.values()) { Location[] matches = matches(location, xz, y, alignment); if (matches != null) { if (clear) { for (Location match : matches) { match.getBlock().setType(Material.AIR); } } return true; } } return false; }
if (i * i + j * j <= radius * radius + 1) { Block block = world.getBlockAt(sourceX + i, sourceY + k, sourceZ + j); block.setType(Material.OBSIDIAN); world.spawnEntity(loc, EntityType.ENDER_CRYSTAL); Block block = world.getBlockAt(sourceX, sourceY + height, sourceZ); block.setType(Material.BEDROCK); return true;
@Override public void onBlockChanged(GlowBlock block, Material oldType, byte oldData, Material newType, byte newData) { if (newType != Material.AIR) { return; } if (oldType.getData() == Door.class) { Door door = new Door(oldType); door.setData(oldData); if (door.isTopHalf()) { Block b = block.getRelative(BlockFace.DOWN); if (b.getState().getData() instanceof Door) { b.setType(Material.AIR); } } else { Block b = block.getRelative(BlockFace.UP); if (b.getState().getData() instanceof Door) { b.setType(Material.AIR); } } } }
/** * Convert a TNT block into a primed TNT entity with the player who ignited the TNT. * * @param tntBlock The block to ignite. * @param ignitedByExplosion True if another explosion caused this ignition. * @param player The player who ignited the TNT. */ public static void igniteBlock( Block tntBlock, boolean ignitedByExplosion, GlowPlayer player) { tntBlock.setType(Material.AIR); World world = tntBlock.getWorld(); GlowTntPrimed tnt = (GlowTntPrimed) world .spawnEntity(tntBlock.getLocation().add(0.5, 0, 0.5), EntityType.PRIMED_TNT); tnt.setSource(player); tnt.setIgnitedByExplosion(ignitedByExplosion); world.playSound(tntBlock.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); }
target.setType(Material.AIR);
sponge.setType(SpongeType.WET); do { iterator.next().setType(Material.AIR); } while (iterator.hasNext());
final Block block = player.getLocation().subtract(0, 1, 0).getBlock(); //get the block final Material type = block.getType(); //get the block's type block.setType(Material.GLOWSTONE); //set the block's material to glowstone Bukkit.getScheduler().runTaskLater(Magic.getInstance(), new Runnable(){ public void run(){ block.setType(type); //set the block back to the original block } },10L);
@Override public void tick(Block b, SlimefunItem item, Config data) { if (MaterialHelper.isWool(b.getType())){ b.setType(MaterialHelper.WoolColours[meta], false); }else if (MaterialHelper.isStainedGlass(b.getType())) { b.setType(MaterialHelper.StainedGlassColours[meta], false); }else if (MaterialHelper.isStainedGlassPane(b.getType())){ b.setType(MaterialHelper.StainedGlassPaneColours[meta], true); }else if (MaterialHelper.isTerracotta(b.getType())){ b.setType(MaterialHelper.TerracottaColours[meta], false); } }
private void checkAndDestroy(World world, int x, int y, int z, Material required) { if (world.getBlockAt(x, y, z).getType() == required) { world.getBlockAt(x, y, z).setType(Material.AIR); } }
Block block; // ... block.setType(Material.STANDING_BANNER); Banner banner = (Banner)block.getState(); banner.setBaseColor(DyeColor.RED); banner.update();
@Override public void run() { source.getBlock().setType(Material.LAVA); source.getWorld().createExplosion(source, 0F, false); } });
public void repair() { Block b = getWorld().getBlockAt(x,y,z); if (b.getType() == Material.AIR) b.setType(Material.STONE); super.repair(); } }
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) { if (!arena.getReadyPlayersInLobby().contains(event.getPlayer()) && !arena.inArena(event.getPlayer())) return; if (!arena.isRunning()) { event.getBlockClicked().getRelative(event.getBlockFace()).setType(Material.AIR); event.setCancelled(true); return; } Block liquid = event.getBlockClicked().getRelative(event.getBlockFace()); arena.addBlock(liquid); }