Search in sources :

Example 16 with BlockFace

use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.

the class LavaDecorator 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 = flowing ? 4 + random.nextInt(120) : 10 + random.nextInt(108);
    Block block = world.getBlockAt(sourceX, sourceY, sourceZ);
    if ((block.getType() == Material.NETHERRACK || block.isEmpty()) && block.getRelative(BlockFace.UP).getType() == Material.NETHERRACK) {
        int netherrackBlockCount = 0;
        for (BlockFace face : SIDES) {
            if (block.getRelative(face).getType() == Material.NETHERRACK) {
                netherrackBlockCount++;
            }
        }
        int airBlockCount = 0;
        for (BlockFace face : SIDES) {
            if (block.getRelative(face).isEmpty()) {
                airBlockCount++;
            }
        }
        if (netherrackBlockCount == 5 || flowing && airBlockCount == 1 && netherrackBlockCount == 4) {
            BlockState state = block.getState();
            state.setType(Material.LAVA);
            state.update(true);
            new PulseTask((GlowBlock) block, 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)

Example 17 with BlockFace

use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.

the class ItemItemFrame method rightClickBlock.

@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc) {
    GlowItemFrame entity = new GlowItemFrame(player, target.getLocation().getBlock().getRelative(face).getLocation(), face);
    List<Message> spawnMessage = entity.createSpawnMessage();
    entity.getWorld().getRawPlayers().stream().filter(p -> p.canSeeEntity(entity)).forEach(p -> p.getSession().sendAll(spawnMessage.toArray(new Message[spawnMessage.size()])));
}
Also used : Vector(org.bukkit.util.Vector) GlowBlock(net.glowstone.block.GlowBlock) List(java.util.List) Message(com.flowpowered.network.Message) GlowPlayer(net.glowstone.entity.GlowPlayer) BlockFace(org.bukkit.block.BlockFace) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame) ItemStack(org.bukkit.inventory.ItemStack) Message(com.flowpowered.network.Message) GlowItemFrame(net.glowstone.entity.objects.GlowItemFrame)

Example 18 with BlockFace

use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.

the class BlockRedstoneRepeater method extraUpdate.

private void extraUpdate(GlowBlock block) {
    Diode diode = (Diode) block.getState().getData();
    ItemTable itemTable = ItemTable.instance();
    GlowBlock target = block.getRelative(diode.getFacing());
    if (target.getType().isSolid()) {
        for (BlockFace face2 : ADJACENT) {
            GlowBlock target2 = target.getRelative(face2);
            BlockType notifyType = itemTable.getBlock(target2.getTypeId());
            if (notifyType != null) {
                if (target2.getFace(block) == null) {
                    notifyType.onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData());
                }
                notifyType.onRedstoneUpdate(target2);
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) Diode(org.bukkit.material.Diode) ItemTable(net.glowstone.block.ItemTable) BlockFace(org.bukkit.block.BlockFace)

Example 19 with BlockFace

use of org.bukkit.block.BlockFace in project Glowstone by GlowstoneMC.

the class BlockRedstoneTorch method extraUpdate.

private void extraUpdate(GlowBlock block) {
    ItemTable itemTable = ItemTable.instance();
    GlowBlock target = block.getRelative(BlockFace.UP);
    if (target.getType().isSolid()) {
        for (BlockFace face2 : ADJACENT) {
            GlowBlock target2 = target.getRelative(face2);
            BlockType notifyType = itemTable.getBlock(target2.getTypeId());
            if (notifyType != null) {
                if (target2.getFace(block) == null) {
                    notifyType.onNearBlockChanged(target2, BlockFace.SELF, block, block.getType(), block.getData(), block.getType(), block.getData());
                }
                notifyType.onRedstoneUpdate(target2);
            }
        }
    }
}
Also used : GlowBlock(net.glowstone.block.GlowBlock) ItemTable(net.glowstone.block.ItemTable) BlockFace(org.bukkit.block.BlockFace)

Example 20 with BlockFace

use of org.bukkit.block.BlockFace in project BKCommonLib by bergerhealer.

the class EntityMoveHandler method world_getBlockCollisions.

private boolean world_getBlockCollisions(EntityHandle entity, AxisAlignedBBHandle bounds, boolean flag) {
    if (!entity.getWorld().getBlockCollisions(entity, bounds, flag, collisions_buffer)) {
        return false;
    }
    org.bukkit.World bWorld = entity.getWorld().getWorld();
    // Send all found bounds in the list through a filter calling onBlockCollision
    // Handle block collisions
    BlockFace hitFace;
    Iterator<AxisAlignedBBHandle> iter = collisions_buffer.iterator();
    AxisAlignedBBHandle blockBounds;
    double dx, dz;
    while (iter.hasNext()) {
        blockBounds = iter.next();
        // Convert to block and block coordinates
        org.bukkit.block.Block block = bWorld.getBlockAt(MathUtil.floor(blockBounds.getMinX()), MathUtil.floor(blockBounds.getMinY()), MathUtil.floor(blockBounds.getMinZ()));
        // Find out what direction the block is hit
        if (bounds.getMaxY() > blockBounds.getMaxY()) {
            hitFace = BlockFace.UP;
        } else if (bounds.getMinY() < blockBounds.getMinY()) {
            hitFace = BlockFace.DOWN;
        } else {
            dx = entity.getLocX() - block.getX() - 0.5;
            dz = entity.getLocZ() - block.getZ() - 0.5;
            hitFace = FaceUtil.getDirection(dx, dz, false);
        }
        // Block collision event
        if (!controller.onBlockCollision(block, hitFace)) {
            iter.remove();
        }
    }
    return true;
}
Also used : AxisAlignedBBHandle(com.bergerkiller.generated.net.minecraft.server.AxisAlignedBBHandle) BlockFace(org.bukkit.block.BlockFace)

Aggregations

BlockFace (org.bukkit.block.BlockFace)50 GlowBlock (net.glowstone.block.GlowBlock)20 Block (org.bukkit.block.Block)17 MaterialData (org.bukkit.material.MaterialData)9 BlockState (org.bukkit.block.BlockState)8 Vector (org.bukkit.util.Vector)8 GlowBlockState (net.glowstone.block.GlowBlockState)6 Location (org.bukkit.Location)6 ItemStack (org.bukkit.inventory.ItemStack)6 ItemTable (net.glowstone.block.ItemTable)5 BlockType (net.glowstone.block.blocktype.BlockType)4 PulseTask (net.glowstone.scheduler.PulseTask)4 Sign (org.bukkit.block.Sign)4 ArrayList (java.util.ArrayList)3 GlowPlayer (net.glowstone.entity.GlowPlayer)3 GlowWorld (net.glowstone.GlowWorld)2 BlockLiquid (net.glowstone.block.blocktype.BlockLiquid)2 ItemType (net.glowstone.block.itemtype.ItemType)2 Material (org.bukkit.Material)2 Action (org.bukkit.event.block.Action)2