public interface BlockState extends Metadatable
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.
Modifier and Type | Method and Description |
---|---|
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.
|
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
|
boolean |
isPlaced()
Returns whether this state is placed in the world.
|
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.
|
getMetadata, hasMetadata, removeMetadata, setMetadata
Block getBlock()
MaterialData getData()
Material getType()
@Deprecated int getTypeId()
byte getLightLevel()
World getWorld()
int getX()
int getY()
int getZ()
Location getLocation()
Location getLocation(Location loc)
If the provided Location is null this method does nothing and returns null.
loc
- the location to copy intoChunk getChunk()
void setData(MaterialData data)
data
- New block specific metadatavoid setType(Material type)
type
- Material to change this block to@Deprecated boolean setTypeId(int type)
type
- Type-Id to change this block toboolean update()
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.
update(boolean)
boolean update(boolean force)
This has the same effect as calling update(force, true). That is to say, this will trigger a physics update to surrounding blocks.
force
- true to forcefully set the stateboolean update(boolean force, boolean applyPhysics)
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.
force
- true to forcefully set the stateapplyPhysics
- false to cancel updating physics on surrounding
blocks@Deprecated byte getRawData()
@Deprecated void setRawData(byte data)
data
- The new data value for the block.boolean isPlaced()
Copyright © 2017. All rights reserved.