@Override public boolean canSpawn(World world, int x, int z) { Block block = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN); return block.getType() == Material.NETHERRACK; }
@Override public boolean canSpawn(World world, int x, int z) { Block block = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN); return block.getType() == Material.ENDER_STONE; }
@Override public boolean canSpawn(World world, int x, int z) { Block block = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN); return !block.isLiquid() && !block.isEmpty() && !noSpawnFloors.contains(block.getType()); }
double x = radius * Math.sin(angle) + centerX; double z = radius * Math.cos(angle) + centerZ; Block block = world.getHighestBlockAt(new Location(world, x, 0, z)); if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA
@Override public void render(MapView map, MapCanvas canvas, Player player) { World world = map.getWorld(); int scaleShift = map.getScale().getValue(); Location playerLoc = player.getLocation(); int playerX = playerLoc.getBlockX(); int playerZ = playerLoc.getBlockZ(); int cornerX = map.getCenterX() - ((MAP_SIZE / 2) << scaleShift); int cornerZ = map.getCenterZ() - ((MAP_SIZE / 2) << scaleShift); for (int pixelX = 0; pixelX < MAP_SIZE; pixelX++) { for (int pixelY = 0; pixelY < MAP_SIZE; pixelY++) { int worldX = cornerX + (pixelX << scaleShift); int worldZ = cornerZ + (pixelY << scaleShift); if (((worldX - playerX) * (worldX - playerX) + (worldZ - playerZ) * (worldZ - playerZ)) < MAP_SIGHT_DISTANCE_SQUARED) { // TODO: Should the highest block be skipped over if it's e.g. a flower or a // technical block? byte blockColor = colorFor(world.getHighestBlockAt(worldX, worldZ), worldX, worldZ); canvas.setPixel(pixelX, pixelY, blockColor); } } } }
/** * Get a random player's location (must be outdoors, specifically: no block overhead) */ private Location getOutdoorPlayerLocation(World world) { Location location = null; List<Player> players = world.getPlayers(); if (players.size() > 0) { Player player = players.get(ThreadLocalRandom.current().nextInt(0, players.size())); if (world.getHighestBlockAt(player.getLocation()).getY() < player.getLocation().getY()) { location = player.getLocation(); } } return location; }
@Override public boolean canSpawn(World world, int x, int z) { makeSureWorldIsInitialized(world); Material material = world.getHighestBlockAt(x, z).getType(); return material.isSolid(); }
/** * Set a random set of loaded blocks on fire */ private void setFire(World world, int blocks) { if (world != null) { int count = world.getLoadedChunks().length; for (int i = 0; i < blocks; i++) { int chunkIndex = GlobalWarming.getInstance().getRandom().nextInt(count); Chunk chunk = world.getLoadedChunks()[chunkIndex]; int x = (chunk.getX() * BLOCKS_PER_CHUNK) + GlobalWarming.getInstance().getRandom().nextInt(BLOCKS_PER_CHUNK); int z = (chunk.getZ() * BLOCKS_PER_CHUNK) + GlobalWarming.getInstance().getRandom().nextInt(BLOCKS_PER_CHUNK); Block topBlock = world.getHighestBlockAt(x, z); topBlock.getRelative(BlockFace.UP).setType(Material.FIRE); } } }
} else { player.sendMessage("Leaving CityWorld... Come back soon!"); player.teleport(world.getHighestBlockAt(world.getSpawnLocation()).getLocation()); return true;
int maz = a.getMaxZ(); World w = plugin.getServer().getWorld(a.getWorld()); Block b1 = w.getHighestBlockAt(mix, miz).getRelative(BlockFace.UP); b1.setBlockData(SNOW); Block b2 = w.getHighestBlockAt(mix, maz).getRelative(BlockFace.UP); b2.setBlockData(SNOW); Block b3 = w.getHighestBlockAt(max, miz).getRelative(BlockFace.UP); b3.setBlockData(SNOW); Block b4 = w.getHighestBlockAt(max, maz).getRelative(BlockFace.UP); b4.setBlockData(SNOW); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SetAir(b1, b2, b3, b4), 300L);
public Location ejectPlayer(Player player) { //look for a suitable location Location candidateLocation = player.getLocation(); while(true) { Claim claim = null; claim = GriefPrevention.instance.dataStore.getClaimAt(candidateLocation, false, null); //if there's a claim here, keep looking if(claim != null) { candidateLocation = new Location(claim.lesserBoundaryCorner.getWorld(), claim.lesserBoundaryCorner.getBlockX() - 1, claim.lesserBoundaryCorner.getBlockY(), claim.lesserBoundaryCorner.getBlockZ() - 1); continue; } //otherwise find a safe place to teleport the player else { //find a safe height, a couple of blocks above the surface GuaranteeChunkLoaded(candidateLocation); Block highestBlock = candidateLocation.getWorld().getHighestBlockAt(candidateLocation.getBlockX(), candidateLocation.getBlockZ()); Location destination = new Location(highestBlock.getWorld(), highestBlock.getX(), highestBlock.getY() + 2, highestBlock.getZ()); player.teleport(destination); return destination; } } }
y = plugin.getUtils().getHighestNetherBlock(l.getWorld(), wx, wz); } else { y = l.getWorld().getHighestBlockAt(l).getY();
y = plugin.getUtils().getHighestNetherBlock(adjusted_location.getWorld(), wx, wz); } else { y = adjusted_location.getWorld().getHighestBlockAt(adjusted_location).getY();
public static void chimaeraExecuteTeleport() { Player player = mcMMOPlayer.getPlayer(); if (Config.getInstance().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) { player.teleport(player.getBedSpawnLocation()); } else { Location spawnLocation = player.getWorld().getSpawnLocation(); if (spawnLocation.getBlock().getType() == Material.AIR) { player.teleport(spawnLocation); } else { player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation()); } } player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - Config.getInstance().getChimaeraUseCost()))); player.updateInventory(); mcMMOPlayer.actualizeChimeraWingLastUse(); mcMMOPlayer.setTeleportCommenceLocation(null); if (Config.getInstance().getChimaeraSoundEnabled()) { SoundManager.sendSound(player, location, SoundType.CHIMAERA_WING); } NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.ChimaeraWing.Pass"); }