public interface Block extends Metadatable
限定符和类型 | 方法和说明 |
---|---|
boolean |
breakNaturally()
Breaks the block and spawns items as if a player had digged it
|
boolean |
breakNaturally(ItemStack tool)
Breaks the block and spawns items as if a player had digged it with a
specific tool
|
Biome |
getBiome()
Returns the biome that this block resides in
|
BlockData |
getBlockData()
Gets the complete block data for this block
|
int |
getBlockPower()
Returns the redstone power being provided to this block
|
int |
getBlockPower(BlockFace face)
Returns the redstone power being provided to this block face
|
BoundingBox |
getBoundingBox()
Gets the approximate bounding box for this block.
|
Chunk |
getChunk()
获取包含此方块的区块(方块所在的区块).
|
byte |
getData()
已过时。
不安全的参数
|
java.util.Collection<ItemStack> |
getDrops()
Returns a list of items which would drop by destroying this block
|
java.util.Collection<ItemStack> |
getDrops(ItemStack tool)
Returns a list of items which would drop by destroying this block with
a specific tool
|
BlockFace |
getFace(Block block)
Gets the face relation of this block compared to the given block.
|
double |
getHumidity()
Gets the humidity of the biome of this block
|
byte |
getLightFromBlocks()
Get the amount of light at this block from nearby blocks.
|
byte |
getLightFromSky()
Get the amount of light at this block from the sky.
|
byte |
getLightLevel()
获取此方块的光亮等级,范围0~15.
|
Location |
getLocation()
获取方块的位置信息.
|
Location |
getLocation(Location loc)
Stores the location of the block in the provided Location object.
|
PistonMoveReaction |
getPistonMoveReaction()
Returns the reaction of the block when moved by a piston
|
Block |
getRelative(BlockFace face)
Gets the block at the given face
This method is equal to getRelative(face, 1)
|
Block |
getRelative(BlockFace face,
int distance)
Gets the block at the given distance of the given face
For example, the following method places water at 100,102,100; two
blocks above 100,100,100.
|
Block |
getRelative(int modX,
int modY,
int modZ)
以指定坐标偏移量获取方块 (相对与方块位置的偏移量).
|
BlockState |
getState()
Captures the current state of this block.
|
double |
getTemperature()
Gets the temperature of this block.
|
Material |
getType()
获取此方块的种类.
|
World |
getWorld()
获取此方块所处的世界.
|
int |
getX()
获取此方块的X坐标.
|
int |
getY()
获取此方块的Y坐标.
|
int |
getZ()
获取此方块的Z坐标.
|
boolean |
isBlockFaceIndirectlyPowered(BlockFace face)
Returns true if the block face is being indirectly powered by Redstone.
|
boolean |
isBlockFacePowered(BlockFace face)
Returns true if the block face is being powered by Redstone.
|
boolean |
isBlockIndirectlyPowered()
Returns true if the block is being indirectly powered by Redstone.
|
boolean |
isBlockPowered()
Returns true if the block is being powered by Redstone.
|
boolean |
isEmpty()
Checks if this block is empty.
|
boolean |
isLiquid()
Checks if this block is liquid.
|
boolean |
isPassable()
Checks if this block is passable.
|
RayTraceResult |
rayTrace(Location start,
Vector direction,
double maxDistance,
FluidCollisionMode fluidCollisionMode)
Performs a ray trace that checks for collision with this specific block
in its current state using its precise collision shape.
|
void |
setBiome(Biome bio)
Sets the biome that this block resides in
|
void |
setBlockData(BlockData data)
Sets the complete data for this block
|
void |
setBlockData(BlockData data,
boolean applyPhysics)
Sets the complete data for this block
|
void |
setType(Material type)
设置这个方块的类型.
|
void |
setType(Material type,
boolean applyPhysics)
Sets the type of this block
|
getMetadata, hasMetadata, removeMetadata, setMetadata
@Deprecated byte getData()
原文:Gets the metadata for this block
BlockData getBlockData()
Block getRelative(int modX, int modY, int modZ)
原文:Gets the block at the given offsets
modX
- X坐标偏移量modY
- Y坐标偏移量modZ
- Z坐标偏移量Block getRelative(BlockFace face)
This method is equal to getRelative(face, 1)
face
- Face of this block to returngetRelative(BlockFace, int)
Block getRelative(BlockFace face, int distance)
For example, the following method places water at 100,102,100; two blocks above 100,100,100.
Block block = world.getBlockAt(100, 100, 100); Block shower = block.getRelative(BlockFace.UP, 2); shower.setType(Material.WATER);
face
- Face of this block to returndistance
- Distance to get the block atMaterial getType()
原文:Gets the type of this block
byte getLightLevel()
原文:Gets the light level between 0-15
byte getLightFromSky()
Any light given from other sources (such as blocks like torches) will be ignored.
byte getLightFromBlocks()
Any light given from other sources (such as the sun) will be ignored.
World getWorld()
原文:Gets the world which contains this Block
int getX()
原文:Gets the x-coordinate of this block
int getY()
原文:Gets the y-coordinate of this block
int getZ()
原文:Gets the z-coordinate of this block
Location getLocation()
原文:Gets the Location of the block
Location getLocation(Location loc)
If the provided Location is null this method does nothing and returns null.
loc
- the location to copy intoChunk getChunk()
原文:Gets the chunk which contains this block
void setBlockData(BlockData data)
data
- new block specific datavoid setBlockData(BlockData data, boolean applyPhysics)
data
- new block specific dataapplyPhysics
- false to cancel physics from the changed blockvoid setType(Material type)
原文:Sets the type of this block
type
- 方块的Material类型void setType(Material type, boolean applyPhysics)
type
- Material to change this block toapplyPhysics
- False to cancel physics on the changed block.BlockFace getFace(Block block)
For example:
Block current = world.getBlockAt(100, 100, 100);
Block target = world.getBlockAt(100, 101, 100);
current.getFace(target) == BlockFace.Up;
block
- Block to compare against this blockBlockState getState()
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.
Biome getBiome()
void setBiome(Biome bio)
bio
- new Biome type for this blockboolean isBlockPowered()
boolean isBlockIndirectlyPowered()
boolean isBlockFacePowered(BlockFace face)
face
- The block faceboolean isBlockFaceIndirectlyPowered(BlockFace face)
face
- The block faceint getBlockPower(BlockFace face)
face
- the face of the block to query or BlockFace.SELF for the
block itselfint getBlockPower()
boolean isEmpty()
A block is considered empty when getType()
returns Material.AIR
.
boolean isLiquid()
A block is considered liquid when getType()
returns Material.WATER
or Material.LAVA
.
double getTemperature()
If the raw biome temperature without adjusting for height effects is
required then please use World.getTemperature(int, int)
.
double getHumidity()
PistonMoveReaction getPistonMoveReaction()
boolean breakNaturally()
boolean breakNaturally(ItemStack tool)
tool
- The tool or item in hand used for diggingjava.util.Collection<ItemStack> getDrops()
java.util.Collection<ItemStack> getDrops(ItemStack tool)
tool
- The tool or item in hand used for diggingboolean isPassable()
A block is passable if it has no colliding parts that would prevent players from moving through it.
Examples: Tall grass, flowers, signs, etc. are passable, but open doors, fence gates, trap doors, etc. are not because they still have parts that can be collided with.
true
if passableRayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode)
start
- the start locationdirection
- the ray directionmaxDistance
- the maximum distancefluidCollisionMode
- the fluid collision modenull
if there is no hitBoundingBox getBoundingBox()
This isn't exact as some blocks Stairs
contain many bounding boxes to establish their complete form.
Also, the box may not be exactly the same as the collision shape (such as
cactus, which is 16/16 of a block with 15/16 collisional bounds).
This method will return an empty bounding box if the geometric shape of
the block is empty (such as air blocks).