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));
}
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 BlockSoil method updateBlock.
@Override
public void updateBlock(GlowBlock block) {
if (isNearWater(block) || GlowBiomeClimate.isRainy(block)) {
// set this block as fully wet
block.setData((byte) 7);
} else if (block.getData() > 0) {
// if this block is wet, it becomes less wet
block.setData((byte) (block.getData() - 1));
} else if (!Arrays.asList(possibleCrops).contains(block.getRelative(BlockFace.UP).getType())) {
// turns block back to dirt if nothing is planted on
GlowBlockState state = block.getState();
state.setType(Material.DIRT);
state.setRawData((byte) 0);
BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state);
EventFactory.callEvent(fadeEvent);
if (!fadeEvent.isCancelled()) {
state.update(true);
}
}
}
use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class ItemSeeds method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc) {
if (target.getType() == soilType && target.getRelative(BlockFace.UP).getType() == Material.AIR && face == BlockFace.UP) {
GlowBlockState state = target.getRelative(BlockFace.UP).getState();
state.setType(cropsType);
state.setRawData((byte) 0);
state.update(true);
// deduct from stack if not in creative mode
if (player.getGameMode() != GameMode.CREATIVE) {
holding.setAmount(holding.getAmount() - 1);
}
}
}
Aggregations