Added helper methods World.getHighestBlockAt, Block.isEmpty, Block.isLiquid. Added methods to safely retrieve biome/temperature/humidity data for a block without generating the block.

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-07-13 06:52:19 +01:00
parent 7bcdc12da0
commit c68daa00bd
2 changed files with 88 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.bukkit.block.Biome;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
@ -74,6 +75,25 @@ public interface World {
*/ */
public int getHighestBlockYAt(Location location); public int getHighestBlockYAt(Location location);
/**
* Gets the highest non-empty block at the given coordinates
*
* @param x X-coordinate of the block
* @param z Z-coordinate of the block
*
* @return Highest non-empty block
*/
public Block getHighestBlockAt(int x, int z);
/**
* Gets the highest non-empty block at the given coordinates
*
* @param location Coordinates to get the highest block
*
* @return Highest non-empty block
*/
public Block getHighestBlockAt(Location location);
/** /**
* Gets the {@link Chunk} at the given coordinates * Gets the {@link Chunk} at the given coordinates
* *
@ -651,6 +671,42 @@ public interface World {
*/ */
public boolean getAllowMonsters(); public boolean getAllowMonsters();
/**
* Gets the biome for the given block coordinates.
*
* It is safe to run this method when the block does not exist, it will not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
*
* @return Biome of the requested block
*/
public Biome getBiome(int x, int z);
/**
* Gets the temperature for the given block coordinates.
*
* It is safe to run this method when the block does not exist, it will not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
*
* @return Temperature of the requested block
*/
public double getTemperature(int x, int z);
/**
* Gets the humidity for the given block coordinates.
*
* It is safe to run this method when the block does not exist, it will not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
*
* @return Humidity of the requested block
*/
public double getHumidity(int x, int z);
/** /**
* Represents various map environment types that a world may be * Represents various map environment types that a world may be
*/ */

View File

@ -236,4 +236,36 @@ public interface Block {
* @return * @return
*/ */
int getBlockPower(); int getBlockPower();
/**
* Checks if this block is empty.
*
* A block is considered empty when {@link #getType()} returns {@link Material#AIR}.
*
* @return true if this block is empty
*/
boolean isEmpty();
/**
* Checks if this block is liquid.
*
* A block is considered liquid when {@link #getType()} returns {@link Material#WATER}, {@link Material#STATIONARY_WATER}, {@link Material#LAVA} or {@link Material#STATIONARY_LAVA}.
*
* @return true if this block is liquid
*/
boolean isLiquid();
/**
* Gets the temperature of the biome of this block
*
* @return Temperature of this block
*/
double getTemperature();
/**
* Gets the humidity of the biome of this block
*
* @return Humidity of this block
*/
double getHumidity();
} }