Java Code Examples for cn.nukkit.level.Level#getBlock()
The following examples show how to use
cn.nukkit.level.Level#getBlock() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NukkitUtil.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public static BaseBlock getBlock(Level level, Vector position) { Vector3 pos = new Vector3(position.getX(), position.getY(), position.getZ()); Block block = level.getBlock(pos); int id = block.getId(); int data = block.getDamage(); return new BaseBlock(id, data); }
Example 2
Source File: FoodChorusFruit.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override protected boolean onEatenBy(Player player) { super.onEatenBy(player); // Teleportation int minX = player.getFloorX() - 8; int minY = player.getFloorY() - 8; int minZ = player.getFloorZ() - 8; int maxX = minX + 16; int maxY = minY + 16; int maxZ = minZ + 16; Level level = player.getLevel(); if (level == null) return false; NukkitRandom random = new NukkitRandom(); for (int attempts = 0; attempts < 128; attempts++) { int x = random.nextRange(minX, maxX); int y = random.nextRange(minY, maxY); int z = random.nextRange(minZ, maxZ); if (y < 0) continue; while (y >= 0 && !level.getBlock(new Vector3(x, y + 1, z)).isSolid()) { y--; } y++; // Back up to non solid Block blockUp = level.getBlock(new Vector3(x, y + 1, z)); Block blockUp2 = level.getBlock(new Vector3(x, y + 2, z)); if (blockUp.isSolid() || blockUp instanceof BlockLiquid || blockUp2.isSolid() || blockUp2 instanceof BlockLiquid) { continue; } // Sounds are broadcast at both source and destination level.addSound(player.asBlockVector3().asVector3(), Sound.MOB_ENDERMEN_PORTAL); player.teleport(new Vector3(x + 0.5, y + 1, z + 0.5), PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); level.addSound(player.asBlockVector3().asVector3(), Sound.MOB_ENDERMEN_PORTAL); break; } return true; }