Search in sources :

Example 56 with GlowBlock

use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.

the class ItemFlintAndSteel method setBlockOnFire.

private boolean setBlockOnFire(GlowPlayer player, GlowBlock clicked, BlockFace face, ItemStack holding, Vector clickedLoc) {
    GlowBlock fireBlock = clicked.getRelative(face);
    if (fireBlock.getType() != Material.AIR) {
        return true;
    }
    if (!clicked.isFlammable() && clicked.getRelative(BlockFace.DOWN).getType() == Material.AIR) {
        return true;
    }
    BlockIgniteEvent event = EventFactory.callEvent(new BlockIgniteEvent(fireBlock, IgniteCause.FLINT_AND_STEEL, player, null));
    if (event.isCancelled()) {
        player.setItemInHand(holding);
        return false;
    }
    // clone holding to avoid decreasing of the item's amount
    ItemTable.instance().getBlock(Material.FIRE).rightClickBlock(player, clicked, face, holding.clone(), clickedLoc);
    return true;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) BlockIgniteEvent(org.bukkit.event.block.BlockIgniteEvent)

Example 57 with GlowBlock

use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.

the class BlockSapling method searchSourceBlockForHugeTree.

private GlowBlock searchSourceBlockForHugeTree(GlowBlock block) {
    GlowWorld world = block.getWorld();
    int sourceX = block.getX();
    int sourceY = block.getY();
    int sourceZ = block.getZ();
    int data = block.getData();
    for (int x = -1; x <= 0; x++) {
        for (int z = -1; z <= 0; z++) {
            GlowBlock b = world.getBlockAt(sourceX + x, sourceY, sourceZ + z);
            if (b.getType() == Material.SAPLING && b.getData() == data && b.getRelative(BlockFace.SOUTH).getType() == Material.SAPLING && b.getRelative(BlockFace.SOUTH).getData() == data && b.getRelative(BlockFace.EAST).getType() == Material.SAPLING && b.getRelative(BlockFace.EAST).getData() == data && b.getRelative(BlockFace.SOUTH_EAST).getType() == Material.SAPLING && b.getRelative(BlockFace.SOUTH_EAST).getData() == data) {
                return b;
            }
        }
    }
    return null;
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) GlowWorld(net.glowstone.GlowWorld)

Example 58 with GlowBlock

use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.

the class BlockRedstoneRepeater method updatePhysics.

@Override
public void updatePhysics(GlowBlock me) {
    super.updatePhysics(me);
    Diode diode = (Diode) me.getState().getData();
    GlowBlock target = me.getRelative(diode.getFacing().getOppositeFace());
    boolean powered = target.getType() == Material.REDSTONE_TORCH_ON || target.isBlockPowered() || target.getType() == Material.REDSTONE_WIRE && target.getData() > 0 && BlockRedstone.calculateConnections(target).contains(diode.getFacing()) || target.getType() == Material.DIODE_BLOCK_ON && ((Diode) target.getState().getData()).getFacing() == diode.getFacing();
    if (powered != (me.getType() == Material.DIODE_BLOCK_ON)) {
        me.getWorld().requestPulse(me);
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) Diode(org.bukkit.material.Diode)

Example 59 with GlowBlock

use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.

the class GlowFallingBlock method placeFallingBlock.

private void placeFallingBlock() {
    location.getBlock().setTypeIdAndData(material.getId(), getBlockData(), true);
    if (getBlockEntityCompoundTag() != null) {
        if (location.getBlock() instanceof GlowBlock) {
            GlowBlock block = (GlowBlock) location.getBlock();
            BlockEntity blockEntity = block.getBlockEntity();
            if (blockEntity != null) {
                blockEntity.loadNbt(getBlockEntityCompoundTag());
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) BlockEntity(net.glowstone.block.entity.BlockEntity)

Example 60 with GlowBlock

use of net.glowstone.block.GlowBlock in project Glowstone by GlowstoneMC.

the class FlowingLiquidDecorator method decorate.

@Override
public void decorate(World world, Random random, Chunk source) {
    int sourceX = (source.getX() << 4) + random.nextInt(16);
    int sourceZ = (source.getZ() << 4) + random.nextInt(16);
    int sourceY = random.nextInt(random.nextInt(type == Material.LAVA ? random.nextInt(240) + 8 : 248) + 8);
    Block block = world.getBlockAt(sourceX, sourceY, sourceZ);
    if ((block.getType() == Material.STONE || block.getType() == Material.AIR) && block.getRelative(BlockFace.DOWN).getType() == Material.STONE && block.getRelative(BlockFace.UP).getType() == Material.STONE) {
        int stoneBlockCount = 0;
        for (BlockFace face : SIDES) {
            if (block.getRelative(face).getType() == Material.STONE) {
                stoneBlockCount++;
            }
        }
        if (stoneBlockCount == 3) {
            int airBlockCount = 0;
            for (BlockFace face : SIDES) {
                if (block.getRelative(face).isEmpty()) {
                    airBlockCount++;
                }
            }
            if (airBlockCount == 1) {
                BlockState state = block.getState();
                state.setType(type);
                state.update(true);
                new PulseTask((GlowBlock) state.getBlock(), true, 1, true).startPulseTask();
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) BlockState(org.bukkit.block.BlockState) BlockFace(org.bukkit.block.BlockFace) GlowBlock(net.glowstone.block.GlowBlock) Block(org.bukkit.block.Block) PulseTask(net.glowstone.scheduler.PulseTask)

Aggregations

GlowBlock (net.glowstone.block.GlowBlock)72 BlockFace (org.bukkit.block.BlockFace)23 GlowBlockState (net.glowstone.block.GlowBlockState)21 Block (org.bukkit.block.Block)16 GlowWorld (net.glowstone.GlowWorld)14 MaterialData (org.bukkit.material.MaterialData)13 ItemTable (net.glowstone.block.ItemTable)10 BlockType (net.glowstone.block.blocktype.BlockType)7 ItemType (net.glowstone.block.itemtype.ItemType)7 Material (org.bukkit.Material)7 Vector (org.bukkit.util.Vector)7 BlockEntity (net.glowstone.block.entity.BlockEntity)6 ItemStack (org.bukkit.inventory.ItemStack)6 BlockVector (org.bukkit.util.BlockVector)5 Message (com.flowpowered.network.Message)4 IOException (java.io.IOException)4 GlowPlayer (net.glowstone.entity.GlowPlayer)4 Title (com.destroystokyo.paper.Title)3 ByteBufUtils (com.flowpowered.network.util.ByteBufUtils)3 Preconditions (com.google.common.base.Preconditions)3