Java Code Examples for org.bukkit.World#getMaxHeight()
The following examples show how to use
org.bukkit.World#getMaxHeight() .
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: StructureUtil.java From Civs with GNU General Public License v3.0 | 6 votes |
private static void setGlass(World world, double x, double y, double z, Map<Location, Color> boundingBox, Material mat, Player player) { if (y < 1 || y >= world.getMaxHeight()) { return; } Location location = new Location(world, x, y, z); Block block = location.getBlock(); if (block.getType() != Material.AIR || block.getRelative(BlockFace.DOWN).getType() == Material.GRASS_PATH || block.getRelative(BlockFace.DOWN).getType() == Material.FARMLAND) { return; } Color color = Color.RED; if (mat == Material.BLUE_STAINED_GLASS) { color = Color.BLUE; } else if (mat == Material.LIME_STAINED_GLASS) { color = Color.GREEN; } BlockData blockData = mat.createBlockData(); boundingBox.put(new Location(world, x, y, z), color); player.sendBlockChange(location, blockData); }
Example 2
Source File: ChunkGeneratorWorld.java From askyblock with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("deprecation") public byte[][] generateBlockSections(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) { // Bukkit.getLogger().info("DEBUG: world environment = " + // world.getEnvironment().toString()); if (world.getEnvironment().equals(World.Environment.NETHER)) { return generateNetherBlockSections(world, random, chunkX, chunkZ, biomeGrid); } byte[][] result = new byte[world.getMaxHeight() / 16][]; if (Settings.seaHeight == 0) { return result; } else { for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { for (int y = 0; y < Settings.seaHeight; y++) { setBlock(result, x, y, z, (byte) Material.STATIONARY_WATER.getId()); // Stationary // Water // Allows stuff to fall through into oblivion, thus // keeping lag to a minimum } } } return result; } }
Example 3
Source File: GDPlayerData.java From GriefDefender with MIT License | 5 votes |
@Override public int getMaxClaimLevel() { int maxClaimLevel = GDPermissionManager.getInstance().getInternalOptionValue(TypeToken.of(Integer.class), this.getSubject(), Options.MAX_LEVEL); if (!this.checkedDimensionHeight) { final World world = Bukkit.getServer().getWorld(this.worldUniqueId); if (world != null) { final int buildHeight = world.getMaxHeight() - 1; if (buildHeight < maxClaimLevel) { maxClaimLevel = buildHeight; } } this.checkedDimensionHeight = true; } return maxClaimLevel; }
Example 4
Source File: SkyBlockChunkGenerator.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@Override public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid biome) { ChunkData chunkData = createChunkData(world); for (int x = 0; x <= 15; x++) { for (int z = 0; z <= 15; z++) { for (int y = 0; y < world.getMaxHeight(); y++) { biome.setBiome(x, y, z, Biome.OCEAN); } } } return chunkData; }
Example 5
Source File: UtilsMc.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
public static Location airLocation(Location loc) { World world = loc.getWorld(); int x = loc.getBlockX(); int y = loc.getBlockY(); int z = loc.getBlockZ(); int maxY = world.getMaxHeight(); while (y < maxY && !NON_TARGETABLE_BLOCKS.contains(world.getBlockAt(x, y, z).getType())) { y++; } return new Location(world, x + 0.5, y + 0.2, z + 0.5); }
Example 6
Source File: SkyblockGenerator.java From IridiumSkyblock with GNU General Public License v2.0 | 4 votes |
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) { if (blockSections == null) { blockSections = new byte[world.getMaxHeight() / 16][]; } return blockSections; }
Example 7
Source File: EmptyChunkGenerator.java From Slime with MIT License | 4 votes |
@Override public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) { // Leave all sections as null, meaning they aren't populated. return new byte[world.getMaxHeight() / 16][]; }
Example 8
Source File: CraftChunkData.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftChunkData(World world) { this(world.getMaxHeight()); }
Example 9
Source File: WarehouseEffect.java From Civs with GNU General Public License v3.0 | 4 votes |
@Override public void regionCreatedHandler(Region r) { if (!r.getEffects().containsKey(KEY)) { return; } ArrayList<CVInventory> chests = new ArrayList<>(); chests.add(UnloadedInventoryHandler.getInstance().getChestInventory(r.getLocation())); RegionType rt = (RegionType) ItemManager.getInstance().getItemType(r.getType()); double lx = Math.floor(r.getLocation().getX()) + 0.4; double ly = Math.floor(r.getLocation().getY()) + 0.4; double lz = Math.floor(r.getLocation().getZ()) + 0.4; double buildRadius = rt.getBuildRadius(); int x = (int) Math.round(lx - buildRadius); int y = (int) Math.round(ly - buildRadius); y = y < 0 ? 0 : y; int z = (int) Math.round(lz - buildRadius); int xMax = (int) Math.round(lx + buildRadius); int yMax = (int) Math.round(ly + buildRadius); World world = r.getLocation().getWorld(); if (world != null) { yMax = yMax > world.getMaxHeight() - 1 ? world.getMaxHeight() - 1 : yMax; int zMax = (int) Math.round(lz + buildRadius); for (int i = x; i < xMax; i++) { for (int j = y; j < yMax; j++) { for (int k = z; k < zMax; k++) { Block block = world.getBlockAt(i, j, k); if (block.getType() == Material.CHEST) { chests.add(UnloadedInventoryHandler.getInstance().getChestInventory(block.getLocation())); } } } } } File dataFolder = new File(Civs.dataLocation, Constants.REGIONS); if (!dataFolder.exists()) { return; } File dataFile = new File(dataFolder, r.getId() + ".yml"); if (!dataFile.exists()) { Civs.logger.log(Level.SEVERE, "Warehouse region file does not exist {0}.yml", r.getId()); return; } FileConfiguration config = new YamlConfiguration(); try { config.load(dataFile); ArrayList<String> locationList = new ArrayList<>(); for (CVInventory cvInventory : chests) { locationList.add(Region.blockLocationToString(cvInventory.getLocation())); } config.set(Constants.CHESTS, locationList); config.save(dataFile); } catch (Exception e) { e.printStackTrace(); Civs.logger.log(Level.WARNING, UNABLE_TO_SAVE_CHEST, r.getId()); return; } checkExcessChests(r); }
Example 10
Source File: LocationUtil.java From UHC with MIT License | 4 votes |
/** * Checks for the highest safe to stand on block with 2 un-solid blocks above it (excluding above world height). * * <p>Does not teleport on to non-solid blocks or blocks that can damage the player.</p> * <p>Only teleports into water if it is not at head height (feet only)</p> * <p> * If the world type is NETHER then searching will start at 128 instead of the world max height to avoid the * bedrock roof. * </p> * * @param world world to check within * @param xcoord the x coord to check at * @param zcoord the z coord to check at * @return -1 if no valid location found, otherwise coordinate with non-air Y coord with 2 air blocks above it */ public static int findHighestTeleportableY(World world, int xcoord, int zcoord) { final Location startingLocation = new Location( world, xcoord, world.getEnvironment() == World.Environment.NETHER ? NETHER_MAX_HEIGHT : world.getMaxHeight(), zcoord ); boolean above2WasSafe = false; boolean aboveWasSafe = false; boolean above2WasWater = false; boolean aboveWasWater = false; Block currentBlock = startingLocation.getBlock(); Material type; boolean damagesPlayer; boolean canStandOn; boolean aboveAreSafe; while (currentBlock.getY() >= 0) { type = currentBlock.getType(); // get info about the current block damagesPlayer = damagesPlayer(type); canStandOn = canStandOn(type); aboveAreSafe = aboveWasSafe && above2WasSafe && !above2WasWater; // valid block if it has 2 safe blocks above it, it doesn't damage the player, // is safe to stand on and there isn't any water in the head space if (aboveAreSafe && !damagesPlayer && canStandOn) { return currentBlock.getY(); } // move safe blocks above2WasSafe = aboveWasSafe; aboveWasSafe = !canStandOn && !damagesPlayer; // move water blocks above2WasWater = aboveWasWater; aboveWasWater = type == Material.WATER || type == Material.STATIONARY_WATER; // move down a block and run again currentBlock = currentBlock.getRelative(BlockFace.DOWN); } return -1; }