Search in sources :

Example 1 with BlockFadeEvent

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);
        }
    }
}
Also used : BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent) GlowBlockState(net.glowstone.block.GlowBlockState) MaterialData(org.bukkit.material.MaterialData)

Example 2 with BlockFadeEvent

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);
    }
}
Also used : BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent) GlowBlockState(net.glowstone.block.GlowBlockState)

Example 3 with BlockFadeEvent

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);
        }
    }
}
Also used : BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent) GlowBlockState(net.glowstone.block.GlowBlockState)

Example 4 with BlockFadeEvent

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);
        }
    }
}
Also used : BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent) GlowBlockState(net.glowstone.block.GlowBlockState) MaterialData(org.bukkit.material.MaterialData)

Example 5 with BlockFadeEvent

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);
        }
    }
}
Also used : BlockFadeEvent(org.bukkit.event.block.BlockFadeEvent) GlowBlockState(net.glowstone.block.GlowBlockState)

Aggregations

GlowBlockState (net.glowstone.block.GlowBlockState)8 BlockFadeEvent (org.bukkit.event.block.BlockFadeEvent)8 MaterialData (org.bukkit.material.MaterialData)3 GlowWorld (net.glowstone.GlowWorld)2 GlowBlock (net.glowstone.block.GlowBlock)2 BlockSpreadEvent (org.bukkit.event.block.BlockSpreadEvent)2 Material (org.bukkit.Material)1