org.bukkit.block
Interface BlockState

All Superinterfaces:
Metadatable
All Known Subinterfaces:
Beacon, BrewingStand, Chest, CommandBlock, CreatureSpawner, Dispenser, Dropper, Furnace, Hopper, Jukebox, NoteBlock, Sign, Skull

public interface BlockState
extends Metadatable

Represents a captured state of a block, which will not change automatically.

Unlike Block, which only one object can exist per coordinate, BlockState can exist multiple times for any given Block. Note that another plugin may change the state of the block and you will not know, or they may change the block to another type entirely, causing your BlockState to become invalid.


Method Summary
 Block getBlock()
          Gets the block represented by this BlockState
 Chunk getChunk()
          Gets the chunk which contains this block
 MaterialData getData()
          Gets the metadata for this block
 byte getLightLevel()
          Gets the light level between 0-15
 Location getLocation()
          Gets the location of this block
 Location getLocation(Location loc)
          Stores the location of this block in the provided Location object.
If the provided Location is null this method does nothing and returns null.
 byte getRawData()
          Deprecated. Magic value
 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
 void setData(MaterialData data)
          Sets the metadata for this block
 void setRawData(byte data)
          Deprecated. Magic value
 void setType(Material type)
          Sets the type of this block
 boolean setTypeId(int type)
          Deprecated. Magic value
 boolean update()
          Attempts to update the block represented by this state, setting it to the new values as defined by this state.
 boolean update(boolean force)
          Attempts to update the block represented by this state, setting it to the new values as defined by this state.
 boolean update(boolean force, boolean applyPhysics)
          Attempts to update the block represented by this state, setting it to the new values as defined by this state.
 
Methods inherited from interface org.bukkit.metadata.Metadatable
getMetadata, hasMetadata, removeMetadata, setMetadata
 

Method Detail

getBlock

Block getBlock()
Gets the block represented by this BlockState

Returns:
Block that this BlockState represents

getData

MaterialData getData()
Gets the metadata for this block

Returns:
block specific metadata

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

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 this block

Returns:
location

getLocation

Location getLocation(Location loc)
Stores the location of this 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

void setData(MaterialData data)
Sets the metadata for this block

Parameters:
data - New block specific metadata

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 it worked?

update

boolean update()
Attempts to update the block represented by this state, setting it to the new values as defined by this state.

This has the same effect as calling update(false). That is to say, this will not modify the state of a block if it is no longer the same type as it was when this state was taken. It will return false in this eventuality.

Returns:
true if the update was successful, otherwise false
See Also:
update(boolean)

update

boolean update(boolean force)
Attempts to update the block represented by this state, setting it to the new values as defined by this state.

This has the same effect as calling update(force, true). That is to say, this will trigger a physics update to surrounding blocks.

Parameters:
force - true to forcefully set the state
Returns:
true if the update was successful, otherwise false

update

boolean update(boolean force,
               boolean applyPhysics)
Attempts to update the block represented by this state, setting it to the new values as defined by this state.

Unless force is true, this will not modify the state of a block if it is no longer the same type as it was when this state was taken. It will return false in this eventuality.

If force is true, it will set the type of the block to match the new state, set the state data and then return true.

If applyPhysics is true, it will trigger a physics update on surrounding blocks which could cause them to update or disappear.

Parameters:
force - true to forcefully set the state
applyPhysics - false to cancel updating physics on surrounding blocks
Returns:
true if the update was successful, otherwise false

getRawData

@Deprecated
byte getRawData()
Deprecated. Magic value

Returns:
The data as a raw byte.

setRawData

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

Parameters:
data - The new data value for the block.


Copyright © 2013. All Rights Reserved.