Search in sources :

Example 51 with GlowBlockState

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);
                    }
                }
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) GlowBlockState(net.glowstone.block.GlowBlockState) GlowWorld(net.glowstone.GlowWorld)

Example 52 with GlowBlockState

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

Example 53 with GlowBlockState

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

Example 54 with GlowBlockState

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

Aggregations

GlowBlockState (net.glowstone.block.GlowBlockState)54 GlowBlock (net.glowstone.block.GlowBlock)21 MaterialData (org.bukkit.material.MaterialData)20 BlockGrowEvent (org.bukkit.event.block.BlockGrowEvent)11 GlowWorld (net.glowstone.GlowWorld)10 BlockFadeEvent (org.bukkit.event.block.BlockFadeEvent)7 BlockFace (org.bukkit.block.BlockFace)6 BlockSpreadEvent (org.bukkit.event.block.BlockSpreadEvent)5 ItemStack (org.bukkit.inventory.ItemStack)4 Material (org.bukkit.Material)3 Block (org.bukkit.block.Block)3 Door (org.bukkit.material.Door)3 DoublePlant (org.bukkit.material.DoublePlant)3 BlockType (net.glowstone.block.blocktype.BlockType)2 ItemType (net.glowstone.block.itemtype.ItemType)2 GlowDispenser (net.glowstone.block.state.GlowDispenser)2 GlowFlowerPot (net.glowstone.block.state.GlowFlowerPot)2 BlockIgniteEvent (org.bukkit.event.block.BlockIgniteEvent)2 CocoaPlant (org.bukkit.material.CocoaPlant)2 CocoaPlantSize (org.bukkit.material.CocoaPlant.CocoaPlantSize)2