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();
}
}
}
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()])));
}
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);
}
}
}
}
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);
}
}
}
}
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;
}
Aggregations