use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class MushroomDecorator method decorate.
@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);
}
}
}
use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class WaterLilyDecorator method decorate.
@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);
}
}
}
use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class MushroomDecorator method decorate.
@Override
public void decorate(World world, Random random, Chunk source) {
if (random.nextFloat() < density) {
int sourceX = (source.getX() << 4) + random.nextInt(16);
int sourceZ = (source.getZ() << 4) + random.nextInt(16);
int sourceY = world.getHighestBlockYAt(sourceX, sourceZ);
sourceY = fixedHeightRange ? sourceY : random.nextInt(sourceY << 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);
Block block = world.getBlockAt(x, y, z);
Block blockBelow = world.getBlockAt(x, y - 1, z);
if (y < 255 && block.getType() == Material.AIR && ((blockBelow.getType() == Material.GRASS || blockBelow.getState().getData() instanceof Dirt && ((Dirt) blockBelow.getState().getData()).getType() != DirtType.PODZOL) && block.getLightLevel() < 13 || blockBelow.getType() == Material.MYCEL || blockBelow.getState().getData() instanceof Dirt && ((Dirt) blockBelow.getState().getData()).getType() == DirtType.PODZOL)) {
BlockState state = block.getState();
state.setType(type);
state.setData(new MaterialData(type));
state.update(true);
}
}
}
}
use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class BlockSkull method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
super.placeBlock(player, state, face, holding, clickedLoc);
MaterialData data = state.getData();
if (!(data instanceof Skull)) {
warnMaterialData(Skull.class, data);
return;
}
Skull skull = (Skull) data;
skull.setFacingDirection(face);
}
use of org.bukkit.material.MaterialData in project Glowstone by GlowstoneMC.
the class BlockSlab method placeBlock.
@Override
public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) {
super.placeBlock(player, state, face, holding, clickedLoc);
Material blockType = state.getBlock().getType();
if (blockType == Material.STEP) {
state.setType(Material.DOUBLE_STEP);
state.setData(holding.getData());
return;
} else if (blockType == Material.WOOD_STEP) {
state.setType(Material.WOOD_DOUBLE_STEP);
state.setData(holding.getData());
return;
} else if (blockType == Material.STONE_SLAB2) {
state.setType(Material.DOUBLE_STONE_SLAB2);
state.setData(holding.getData());
return;
} else if (blockType == Material.PURPUR_SLAB) {
state.setType(Material.PURPUR_DOUBLE_SLAB);
state.setData(holding.getData());
return;
}
if (face == BlockFace.DOWN || face != BlockFace.UP && clickedLoc.getY() >= 0.5) {
MaterialData data = state.getData();
if (data instanceof Step) {
((Step) data).setInverted(true);
} 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;
}
state.setData(data);
}
}
Aggregations