Moved block stuff from org.bukkit to org.bukkit.block

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-01-15 21:37:08 +00:00
parent 1de48a9184
commit 73edbc4902
26 changed files with 102 additions and 99 deletions

View File

@@ -0,0 +1,20 @@
package org.bukkit.block;
/**
* Holds all accepted Biomes in the default server
*/
public enum Biome {
RAINFOREST,
SWAMPLAND,
SEASONAL_FOREST,
FOREST,
SAVANNA,
SHRUBLAND,
TAIGA,
DESERT,
PLAINS,
ICE_DESERT,
TUNDRA,
HELL
}

View File

@@ -0,0 +1,173 @@
package org.bukkit.block;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockState;
/**
* Represents a block. This is a live object, and only one Block may exist for
* any given location in a world. The state of the block may change concurrently
* to your own handling of it; use block.getState() to get a snapshot state of a
* block which will not be modified.
*/
public interface Block {
/**
* Gets the metadata for this block
*
* @return block specific metadata
*/
byte getData();
/**
* Gets the block at the given face<br />
* <br />
* This method is equal to getFace(face, 1)
*
* @param face Face of this block to return
* @return Block at the given face
* @see Block.getFace(BlockFace face, int distance);
*/
Block getFace(BlockFace face);
/**
* Gets the block at the given distance of the given face<br />
* <br />
* For example, the following method places water at 100,102,100; two blocks
* above 100,100,100.
* <pre>
* Block block = world.getBlockAt(100,100,100);
* Block shower = block.getFace(BlockFace.Up, 2);
* shower.setType(Material.WATER);
* </pre>
*
* @param face Face of this block to return
* @param distance Distance to get the block at
* @return Block at the given face
*/
Block getFace(BlockFace face, int distance);
/**
* Gets the block at the given offsets
*
* @param modX X-coordinate offset
* @param modY Y-coordinate offset
* @param modZ Z-coordinate offset
* @return Block at the given offsets
*/
Block getRelative(int modX, int modY, int modZ);
/**
* Gets the type of this block
*
* @return block type
*/
Material getType();
/**
* Gets the type-id of this block
*
* @return block type-id
*/
int getTypeId();
/**
* Gets the light level between 0-15
*
* @return light level
*/
byte getLightLevel();
/**
* Gets the world which contains this Block
*
* @return World containing this block
*/
World getWorld();
/**
* Gets the x-coordinate of this block
*
* @return x-coordinate
*/
int getX();
/**
* Gets the y-coordinate of this block
*
* @return y-coordinate
*/
int getY();
/**
* Gets the z-coordinate of this block
*
* @return z-coordinate
*/
int getZ();
/**
* Gets the chunk which contains this block
*
* @return Containing Chunk
*/
Chunk getChunk();
/**
* Sets the metadata for this block
*
* @param data New block specific metadata
*/
void setData(byte data);
/**
* Sets the type of this block
*
* @param type Material to change this block to
*/
void setType(Material type);
/**
* Sets the type-id of this block
*
* @param type Type-Id to change this block to
* @return whether the block was changed
*/
boolean setTypeId(int type);
/**
* Gets the face relation of this block compared to the given block<br />
* <br />
* For example:
* <pre>
* Block current = world.getBlockAt(100, 100, 100);
* Block target = world.getBlockAt(100, 101, 100);
*
* current.getFace(target) == BlockFace.Up;
* </pre>
* <br />
* If the given block is not connected to this block, null may be returned
*
* @param block Block to compare against this block
* @return BlockFace of this block which has the requested block, or null
*/
BlockFace getFace(Block block);
/**
* Captures the current state of this block. You may then cast that state
* into any accepted type, such as Furnace or Sign.
*
* The returned object will never be updated, and you are not guaranteed that
* (for example) a sign is still a sign after you capture its state.
*
* @return BlockState with the current state of this block.
*/
BlockState getState();
/**
* Returns the biome that this block resides in
*
* @return Biome type containing this block
*/
Biome getBiome();
}

View File

@@ -0,0 +1,15 @@
package org.bukkit.block;
public enum BlockDamageLevel {
STARTED(0), DIGGING(1), BROKEN(3), STOPPED(2);
private int level;
private BlockDamageLevel(final int level) {
this.level = level;
}
public int getLevel() {
return level;
}
}

View File

@@ -0,0 +1,58 @@
package org.bukkit.block;
/**
* Represents the face of a block
*/
public enum BlockFace {
NORTH(-1, 0, 0),
EAST(0, 0, -1),
SOUTH(1, 0, 0),
WEST(0, 0, 1),
UP(0, 1, 0),
DOWN(0, -1, 0),
NORTH_EAST(NORTH, EAST),
NORTH_WEST(NORTH, WEST),
SOUTH_EAST(SOUTH, EAST),
SOUTH_WEST(SOUTH, WEST),
SELF(0, 0, 0);
private final int modX;
private final int modY;
private final int modZ;
private BlockFace(final int modX, final int modY, final int modZ) {
this.modX = modX;
this.modY = modY;
this.modZ = modZ;
}
private BlockFace(final BlockFace face1, final BlockFace face2) {
this.modX = face1.getModX() + face2.getModX();
this.modY = face1.getModY() + face2.getModY();
this.modZ = face1.getModZ() + face2.getModZ();
}
/**
* Get the amount of X-coordinates to modify to get the represented block
* @return Amount of X-coordinates to modify
*/
public int getModX() {
return modX;
}
/**
* Get the amount of Y-coordinates to modify to get the represented block
* @return Amount of Y-coordinates to modify
*/
public int getModY() {
return modY;
}
/**
* Get the amount of Z-coordinates to modify to get the represented block
* @return Amount of Z-coordinates to modify
*/
public int getModZ() {
return modZ;
}
}

View File

@@ -1,7 +1,6 @@
package org.bukkit.block;
import org.bukkit.Block;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;