use of org.bukkit.event.block.BlockFadeEvent in project Glowstone by GlowstoneMC.
the class BlockSnow method updateBlock.
@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);
}
}
}
use of org.bukkit.event.block.BlockFadeEvent in project Glowstone by GlowstoneMC.
the class BlockLitRedstoneOre method updateBlock.
@Override
public void updateBlock(GlowBlock block) {
GlowBlockState state = block.getState();
state.setType(Material.REDSTONE_ORE);
BlockFadeEvent fadeEvent = new BlockFadeEvent(block, state);
EventFactory.getInstance().callEvent(fadeEvent);
if (!fadeEvent.isCancelled()) {
state.update(true);
}
}
use of org.bukkit.event.block.BlockFadeEvent in project Glowstone by GlowstoneMC.
the class BlockFarmland 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) {
block.setData(// if this block is wet, it becomes less wet
(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.getInstance().callEvent(fadeEvent);
if (!fadeEvent.isCancelled()) {
state.update(true);
}
}
}
use of org.bukkit.event.block.BlockFadeEvent in project Glowstone by GlowstoneMC.
the class BlockSnowBlock method updateBlock.
@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);
}
}
}
use of org.bukkit.event.block.BlockFadeEvent 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);
}
}
}
Aggregations