public OreType(Material type, int minY, int maxY, int amount) { this(type, new MaterialData(type), minY, maxY, amount); }
public OreType(Material type, int minY, int maxY, int amount, Material targetType) { this(type, new MaterialData(type), minY, maxY, amount, targetType); }
switch (getData()) { case 1: return new MaterialData(Material.RED_ROSE); case 2: return new MaterialData(Material.YELLOW_FLOWER); case 3: return new Tree(TreeSpecies.GENERIC); return new Tree(TreeSpecies.JUNGLE); case 7: return new MaterialData(Material.RED_MUSHROOM); case 8: return new MaterialData(Material.BROWN_MUSHROOM); case 9: return new MaterialData(Material.CACTUS); case 10: return new MaterialData(Material.DEAD_BUSH); case 11: return new LongGrass(GrassSpecies.FERN_LIKE);
private void createData(final byte data) { Material mat = Material.getMaterial(type); if (mat == null) { this.data = new MaterialData(type, data); } else { this.data = mat.getNewData(data); } }
private void makeData(byte data) { Material mat = Material.getMaterial(typeId); if (mat == null) { this.data = new MaterialData(typeId, data); } else { this.data = mat.getNewData(data); } }
private void setColoredGroundLayer(ChunkData chunkData, int x, int y, int z, int color) { if (color >= 0) { chunkData.setBlock(x, y, z, new MaterialData(Material.STAINED_CLAY, (byte) color)); } else { chunkData.setBlock(x, y, z, Material.HARD_CLAY); } }
@Override public void playEffect(Location location, Effect effect, int id, int data, float offsetX, float offsetY, float offsetZ, float speed, int particleCount, int radius) { if (effect.getType() == Type.PARTICLE) { MaterialData material = new MaterialData(id, (byte) data); showParticle(location, effect, material, offsetX, offsetY, offsetZ, speed, particleCount); } else { GlowPlayer.this.playEffect(location, effect, data); } }
@Override public void decorate(World world, Random random, Chunk source) { int sourceX = (source.getX() << 4) + random.nextInt(16); int sourceZ = (source.getZ() << 4) + random.nextInt(16); int sourceY = random.nextInt(128); 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); Block blockBelow = world.getBlockAt(x, y - 1, z); if (y < 128 && block.getType() == Material.AIR && Arrays.asList(MATERIALS) .contains(blockBelow.getType())) { BlockState state = block.getState(); state.setType(type); state.setData(new MaterialData(type)); state.update(true); } } } }
@Override public void decorate(World world, Random random, Chunk source) { int amount = 1 + random.nextInt(1 + random.nextInt(10)); for (int j = 0; j < amount; j++) { int sourceX = (source.getX() << 4) + random.nextInt(16); int sourceZ = (source.getZ() << 4) + random.nextInt(16); int sourceY = 4 + random.nextInt(120); 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); Block blockBelow = world.getBlockAt(x, y - 1, z); if (y < 128 && block.getType() == Material.AIR && blockBelow.getType() == Material.NETHERRACK) { BlockState state = block.getState(); state.setType(Material.FIRE); state.setData(new MaterialData(Material.FIRE)); state.update(true); } } } } }
@Override public void populate(World world, Random random, Chunk source) { int sourceX = (source.getX() << 4) + random.nextInt(16); int sourceZ = (source.getZ() << 4) + random.nextInt(16); int sourceY = random.nextInt(world.getSeaLevel() << 1); 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); if (world.getBlockAt(x, y, z).getType() == Material.AIR && world.getBlockAt(x, y - 1, z).getType() == Material.GRASS) { BlockState state = world.getBlockAt(x, y, z).getState(); state.setType(Material.MELON_BLOCK); state.setData(new MaterialData(Material.MELON_BLOCK)); state.update(true); } } } }
@Override public void decorate(World world, Random random, Chunk source) { int sourceX = (source.getX() << 4) + random.nextInt(16); int sourceZ = (source.getZ() << 4) + random.nextInt(16); int sourceY = random.nextInt(world.getHighestBlockYAt(sourceX, sourceZ) << 1); while (world.getBlockAt(sourceX, sourceY - 1, sourceZ).getType() == Material.AIR && sourceY > 0) { sourceY--; } for (int j = 0; j < 10; j++) { 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); if (y >= 0 && y <= 255 && world.getBlockAt(x, y, z).getType() == Material.AIR && world.getBlockAt(x, y - 1, z).getType() == Material.STATIONARY_WATER) { BlockState state = world.getBlockAt(x, y, z).getState(); state.setType(Material.WATER_LILY); state.setData(new MaterialData(Material.WATER_LILY)); state.update(true); } } } }
state.setData(new MaterialData(Material.MOSSY_COBBLESTONE)); state.update(true);
@Override public boolean generate(World world, Random random, int sourceX, int sourceY, int sourceZ) { boolean succeeded = false; int n = random.nextInt(horizRadius - MIN_RADIUS) + MIN_RADIUS; int nsquared = n * n; for (int x = sourceX - n; x <= sourceX + n; x++) { for (int z = sourceZ - n; z <= sourceZ + n; z++) { if ((x - sourceX) * (x - sourceX) + (z - sourceZ) * (z - sourceZ) > nsquared) { continue; } for (int y = sourceY - vertRadius; y <= sourceY + vertRadius; y++) { Block block = world.getBlockAt(x, y, z); if (!overridables.contains(block.getType())) { continue; } if (TerrainObject.killPlantAbove(block)) { break; } BlockState state = block.getState(); state.setType(type); state.setData(new MaterialData(type)); state.update(true); succeeded = true; break; } } } return succeeded; } }
BlockState state = block.getState(); state.setType(type); state.setData(new MaterialData(type)); state.update(true);
@Override public void updateBlock(GlowBlock block) { if (block.getLightFromBlocks() > 11) { GlowBlockState state = block.getState(); state.setType(Material.AIR); state.setData(new MaterialData(Material.AIR)); BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state); EventFactory.getInstance().callEvent(fadeEvent); if (!fadeEvent.isCancelled()) { state.update(true); } } } }
@Override public void updateBlock(GlowBlock block) { if (block.getLightFromBlocks() > 11) { GlowBlockState state = block.getState(); state.setType(Material.AIR); state.setData(new MaterialData(Material.AIR)); BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state); EventFactory.getInstance().callEvent(fadeEvent); if (!fadeEvent.isCancelled()) { state.update(true); } } } }
/** * Generates or extends a cactus, if there is space. */ @Override public boolean generate(World world, Random random, int x, int y, int z) { if (world.getBlockAt(x, y, z).isEmpty()) { int height = random.nextInt(random.nextInt(3) + 1) + 1; for (int n = y; n < y + height; n++) { Block block = world.getBlockAt(x, n, z); Material typeBelow = block.getRelative(BlockFace.DOWN).getType(); if ((typeBelow == Material.SAND || typeBelow == Material.CACTUS) && block.getRelative(BlockFace.UP).isEmpty()) { for (BlockFace face : FACES) { if (block.getRelative(face).getType().isSolid()) { return n > y; } } BlockState state = block.getState(); state.setType(Material.CACTUS); state.setData(new MaterialData(Material.CACTUS)); state.update(true); } } } return true; } }
@Override public void updateBlock(GlowBlock block) { if (block.getLightFromBlocks() > 11 - block.getMaterialValues().getLightOpacity()) { Material type = block.getWorld().getEnvironment() == Environment.NETHER ? Material.AIR : Material.STATIONARY_WATER; GlowBlockState state = block.getState(); state.setType(type); state.setData(new MaterialData(type)); BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state); EventFactory.getInstance().callEvent(fadeEvent); if (!fadeEvent.isCancelled()) { state.update(true); } } } }
@Override public void updateBlock(GlowBlock block) { super.updateBlock(block); if (block.getLightFromBlocks() <= 11 - block.getMaterialValues().getLightOpacity()) { if (block.getRelative(BlockFace.UP).isEmpty() && hasNearSolidBlock(block) && GlowBiomeClimate.isCold(block)) { GlowBlockState state = block.getState(); state.setType(Material.ICE); state.setData(new MaterialData(Material.ICE)); BlockSpreadEvent spreadEvent = new BlockSpreadEvent(state.getBlock(), block, state); EventFactory.getInstance().callEvent(spreadEvent); if (!spreadEvent.isCancelled()) { state.update(true); } } } }
state.setData(new MaterialData(Material.SUGAR_CANE_BLOCK)); state.update(true);