org.bukkit.block
Interface Block

All Superinterfaces:
Metadatable

public interface Block
extends Metadatable

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.


Method Summary
 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
 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
 Chunk getChunk()
          Gets the chunk which contains this block
 byte getData()
          Deprecated. Magic value
 Collection<ItemStack> getDrops()
          Returns a list of items which would drop by destroying this block
 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()
          Gets the light level between 0-15
 Location getLocation()
          Gets the Location of the block
 Location getLocation(Location loc)
          Stores the location of the block in the provided Location object.
If the provided Location is null this method does nothing and returns null.
 PistonMoveReaction getPistonMoveReaction()
          Returns the reaction of the block when moved by a piston
 Block getRelative(BlockFace face)
          Gets the block at the given face
 Block getRelative(BlockFace face, int distance)
          Gets the block at the given distance of the given face
 Block getRelative(int modX, int modY, int modZ)
          Gets the block at the given offsets
 BlockState getState()
          Captures the current state of this block.
 double getTemperature()
          Gets the temperature of the biome of this block
 Material getType()
          Gets the type of this block
 int getTypeId()
          Deprecated. Magic value
 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
 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.
 void setBiome(Biome bio)
          Sets the biome that this block resides in
 void setData(byte data)
          Deprecated. Magic value
 void setData(byte data, boolean applyPhysics)
          Deprecated. Magic value
 void setType(Material type)
          Sets the type of this block
 boolean setTypeId(int type)
          Deprecated. Magic value
 boolean setTypeId(int type, boolean applyPhysics)
          Deprecated. Magic value
 boolean setTypeIdAndData(int type, byte data, boolean applyPhysics)
          Deprecated. Magic value
 
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
 

Method Detail

getData

@Deprecated
byte getData()
Deprecated. Magic value

Gets the metadata for this block

Returns:
block specific metadata

getRelative

Block getRelative(int modX,
                  int modY,
                  int modZ)
Gets the block at the given offsets

Parameters:
modX - X-coordinate offset
modY - Y-coordinate offset
modZ - Z-coordinate offset
Returns:
Block at the given offsets

getRelative

Block getRelative(BlockFace face)
Gets the block at the given face

This method is equal to getRelative(face, 1)

Parameters:
face - Face of this block to return
Returns:
Block at the given face
See Also:
getRelative(BlockFace, int)

getRelative

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 block = world.getBlockAt(100, 100, 100);
 Block shower = block.getRelative(BlockFace.UP, 2);
 shower.setType(Material.WATER);
 

Parameters:
face - Face of this block to return
distance - Distance to get the block at
Returns:
Block at the given face

getType

Material getType()
Gets the type of this block

Returns:
block type

getTypeId

@Deprecated
int getTypeId()
Deprecated. Magic value

Gets the type-id of this block

Returns:
block type-id

getLightLevel

byte getLightLevel()
Gets the light level between 0-15

Returns:
light level

getLightFromSky

byte getLightFromSky()
Get the amount of light at this block from the sky.

Any light given from other sources (such as blocks like torches) will be ignored.

Returns:
Sky light level

getLightFromBlocks

byte getLightFromBlocks()
Get the amount of light at this block from nearby blocks.

Any light given from other sources (such as the sun) will be ignored.

Returns:
Block light level

getWorld

World getWorld()
Gets the world which contains this Block

Returns:
World containing this block

getX

int getX()
Gets the x-coordinate of this block

Returns:
x-coordinate

getY

int getY()
Gets the y-coordinate of this block

Returns:
y-coordinate

getZ

int getZ()
Gets the z-coordinate of this block

Returns:
z-coordinate

getLocation

Location getLocation()
Gets the Location of the block

Returns:
Location of block

getLocation

Location getLocation(Location loc)
Stores the location of the block in the provided Location object.
If the provided Location is null this method does nothing and returns null.

Returns:
The Location object provided or null

getChunk

Chunk getChunk()
Gets the chunk which contains this block

Returns:
Containing Chunk

setData

@Deprecated
void setData(byte data)
Deprecated. Magic value

Sets the metadata for this block

Parameters:
data - New block specific metadata

setData

@Deprecated
void setData(byte data,
                        boolean applyPhysics)
Deprecated. Magic value

Sets the metadata for this block

Parameters:
data - New block specific metadata
applyPhysics - False to cancel physics from the changed block.

setType

void setType(Material type)
Sets the type of this block

Parameters:
type - Material to change this block to

setTypeId

@Deprecated
boolean setTypeId(int type)
Deprecated. Magic value

Sets the type-id of this block

Parameters:
type - Type-Id to change this block to
Returns:
whether the block was changed

setTypeId

@Deprecated
boolean setTypeId(int type,
                             boolean applyPhysics)
Deprecated. Magic value

Sets the type-id of this block

Parameters:
type - Type-Id to change this block to
applyPhysics - False to cancel physics on the changed block.
Returns:
whether the block was changed

setTypeIdAndData

@Deprecated
boolean setTypeIdAndData(int type,
                                    byte data,
                                    boolean applyPhysics)
Deprecated. Magic value

Sets the type-id of this block

Parameters:
type - Type-Id to change this block to
data - The data value to change this block to
applyPhysics - False to cancel physics on the changed block
Returns:
whether the block was changed

getFace

BlockFace getFace(Block block)
Gets the face relation of this block compared to the given block

For example:

 Block current = world.getBlockAt(100, 100, 100);
 Block target = world.getBlockAt(100, 101, 100);

 current.getFace(target) == BlockFace.Up;
 

If the given block is not connected to this block, null may be returned

Parameters:
block - Block to compare against this block
Returns:
BlockFace of this block which has the requested block, or null

getState

BlockState getState()
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.

Returns:
BlockState with the current state of this block.

getBiome

Biome getBiome()
Returns the biome that this block resides in

Returns:
Biome type containing this block

setBiome

void setBiome(Biome bio)
Sets the biome that this block resides in

Parameters:
bio - new Biome type for this block

isBlockPowered

boolean isBlockPowered()
Returns true if the block is being powered by Redstone.

Returns:
True if the block is powered.

isBlockIndirectlyPowered

boolean isBlockIndirectlyPowered()
Returns true if the block is being indirectly powered by Redstone.

Returns:
True if the block is indirectly powered.

isBlockFacePowered

boolean isBlockFacePowered(BlockFace face)
Returns true if the block face is being powered by Redstone.

Parameters:
face - The block face
Returns:
True if the block face is powered.

isBlockFaceIndirectlyPowered

boolean isBlockFaceIndirectlyPowered(BlockFace face)
Returns true if the block face is being indirectly powered by Redstone.

Parameters:
face - The block face
Returns:
True if the block face is indirectly powered.

getBlockPower

int getBlockPower(BlockFace face)
Returns the redstone power being provided to this block face

Parameters:
face - the face of the block to query or BlockFace.SELF for the block itself
Returns:
The power level.

getBlockPower

int getBlockPower()
Returns the redstone power being provided to this block

Returns:
The power level.

isEmpty

boolean isEmpty()
Checks if this block is empty.

A block is considered empty when getType() returns Material.AIR.

Returns:
true if this block is empty

isLiquid

boolean isLiquid()
Checks if this block is liquid.

A block is considered liquid when getType() returns Material.WATER, Material.STATIONARY_WATER, Material.LAVA or Material.STATIONARY_LAVA.

Returns:
true if this block is liquid

getTemperature

double getTemperature()
Gets the temperature of the biome of this block

Returns:
Temperature of this block

getHumidity

double getHumidity()
Gets the humidity of the biome of this block

Returns:
Humidity of this block

getPistonMoveReaction

PistonMoveReaction getPistonMoveReaction()
Returns the reaction of the block when moved by a piston

Returns:
reaction

breakNaturally

boolean breakNaturally()
Breaks the block and spawns items as if a player had digged it

Returns:
true if the block was destroyed

breakNaturally

boolean breakNaturally(ItemStack tool)
Breaks the block and spawns items as if a player had digged it with a specific tool

Parameters:
tool - The tool or item in hand used for digging
Returns:
true if the block was destroyed

getDrops

Collection<ItemStack> getDrops()
Returns a list of items which would drop by destroying this block

Returns:
a list of dropped items for this type of block

getDrops

Collection<ItemStack> getDrops(ItemStack tool)
Returns a list of items which would drop by destroying this block with a specific tool

Parameters:
tool - The tool or item in hand used for digging
Returns:
a list of dropped items for this type of block


Copyright © 2013. All Rights Reserved.