use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockLeaves method blockDestroy.
@Override
public void blockDestroy(GlowPlayer player, GlowBlock block, BlockFace face) {
// vanilla set decay check in a 3x3x3 neighboring when a leaves block is removed
GlowWorld world = block.getWorld();
for (int x = 0; x < 3; x++) {
for (int z = 0; z < 3; z++) {
for (int y = 0; y < 3; y++) {
GlowBlock b = world.getBlockAt(block.getLocation().add(x - 1, y - 1, z - 1));
if (b.getType() == Material.LEAVES || b.getType() == Material.LEAVES_2) {
GlowBlockState state = b.getState();
if ((state.getRawData() & 0x08) == 0 && (state.getRawData() & 0x04) == 0) {
// check decay is off and decay is on
// set decay check on for this leaves block
state.setRawData((byte) (state.getRawData() | 0x08));
state.update(true);
}
}
}
}
}
}
use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockStateDelegate method setTypeAndData.
/**
* Sets a block type and MaterialData, and add it to the BlockState list.
*
* @param world the world which contains the block
* @param x the x-coordinate of this block
* @param y the y-coordinate of this block
* @param z the z-coordinate of this block
* @param type the new type of this block
* @param data the new MaterialData of this block
*/
public void setTypeAndData(World world, int x, int y, int z, Material type, MaterialData data) {
GlowBlockState state = (GlowBlockState) world.getBlockAt(x, y, z).getState();
state.setType(type);
state.setData(data);
blockStateMap.put(world.getBlockAt(x, y, z).getLocation(), state);
}
use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockStateDelegate method setTypeAndRawData.
/**
* Sets a block type, data and add it to the BlockState list.
*
* @param world the world which contains the block
* @param x the x-coordinate of this block
* @param y the y-coordinate of this block
* @param z the z-coordinate of this block
* @param type the new type of this block
* @param data the new data value of this block
*/
public void setTypeAndRawData(World world, int x, int y, int z, Material type, int data) {
GlowBlockState state = (GlowBlockState) world.getBlockAt(x, y, z).getState();
state.setType(type);
state.setRawData((byte) data);
blockStateMap.put(world.getBlockAt(x, y, z).getLocation(), state);
}
use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockStateDelegate method backupBlockState.
/**
* Backups a block state.
*
* @param block the block which state should be backup
*/
public void backupBlockState(Block block) {
blockStateMap.remove(block.getLocation());
blockStateBackupMap.put(block.getLocation(), new GlowBlockState((GlowBlock) block));
}
Aggregations