org.bukkit.World#getMaxHeight ( )源码实例Demo

下面列出了org.bukkit.World#getMaxHeight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Civs   文件: StructureUtil.java
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);
}
 
源代码2 项目: askyblock   文件: ChunkGeneratorWorld.java
@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;
    }
}
 
源代码3 项目: GriefDefender   文件: GDPlayerData.java
@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;
}
 
源代码4 项目: uSkyBlock   文件: SkyBlockChunkGenerator.java
@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;
}
 
源代码5 项目: NBTEditor   文件: UtilsMc.java
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);
}
 
源代码6 项目: IridiumSkyblock   文件: SkyblockGenerator.java
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) {
    if (blockSections == null) {
        blockSections = new byte[world.getMaxHeight() / 16][];
    }
    return blockSections;
}
 
源代码7 项目: Slime   文件: EmptyChunkGenerator.java
@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][];
}
 
源代码8 项目: Kettle   文件: CraftChunkData.java
public CraftChunkData(World world) {
    this(world.getMaxHeight());
}
 
源代码9 项目: Civs   文件: WarehouseEffect.java
@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);
}
 
源代码10 项目: UHC   文件: LocationUtil.java
/**
 * 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;
}