use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockWater method updateBlock.
@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.callEvent(spreadEvent);
if (!spreadEvent.isCancelled()) {
state.update(true);
}
}
}
}
use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockTallGrass method grow.
@Override
public void grow(GlowPlayer player, GlowBlock block) {
MaterialData data = block.getState().getData();
if (data instanceof LongGrass) {
GrassSpecies species = ((LongGrass) data).getSpecies();
if (species == GrassSpecies.NORMAL || species == GrassSpecies.FERN_LIKE) {
GlowBlockState headBlockState = block.getRelative(BlockFace.UP).getState();
if (headBlockState.getType() == Material.AIR) {
DoublePlantSpecies doublePlantSpecies = species == GrassSpecies.FERN_LIKE ? DoublePlantSpecies.LARGE_FERN : DoublePlantSpecies.DOUBLE_TALLGRASS;
GlowBlockState blockState = block.getState();
blockState.setType(Material.DOUBLE_PLANT);
blockState.setData(new DoublePlant(doublePlantSpecies));
headBlockState.setType(Material.DOUBLE_PLANT);
headBlockState.setData(new DoublePlant(DoublePlantSpecies.PLANT_APEX));
BlockGrowEvent growEvent = new BlockGrowEvent(block, blockState);
EventFactory.callEvent(growEvent);
if (!growEvent.isCancelled()) {
blockState.update(true);
headBlockState.update(true);
}
}
}
} else {
warnMaterialData(LongGrass.class, data);
}
}
use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockRedstoneOre method blockInteract.
@Override
public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face, Vector clickedLoc) {
EntityChangeBlockEvent changeBlockEvent = new EntityChangeBlockEvent(player, block, Material.GLOWING_REDSTONE_ORE, (byte) 0);
EventFactory.callEvent(changeBlockEvent);
if (!changeBlockEvent.isCancelled()) {
GlowBlockState state = block.getState();
state.setType(Material.GLOWING_REDSTONE_ORE);
state.update(true);
}
return false;
}
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);
}
}
}
use of net.glowstone.block.GlowBlockState in project Glowstone by GlowstoneMC.
the class BlockFire method burnBlock.
private void burnBlock(GlowBlock block, int burnResistance, int fireAge) {
if (random.nextInt(burnResistance) < block.getMaterialValues().getFireResistance()) {
BlockBurnEvent burnEvent = new BlockBurnEvent(block);
EventFactory.callEvent(burnEvent);
if (!burnEvent.isCancelled()) {
if (block.getType() == Material.TNT) {
BlockTNT.igniteBlock(block, false);
} else {
GlowBlockState state = block.getState();
if (random.nextInt(10 + fireAge) < 5 && !GlowBiomeClimate.isRainy(block)) {
int increasedAge = increaseFireAge(fireAge);
state.setType(Material.FIRE);
state.setRawData((byte) (increasedAge > MAX_FIRE_AGE ? MAX_FIRE_AGE : increasedAge));
} else {
state.setType(Material.AIR);
state.setRawData((byte) 0);
}
state.update(true);
}
}
}
}
Aggregations