Metadatable
Banner
, Barrel
, Beacon
, Bed
, Bell
, BlastFurnace
, BrewingStand
, Campfire
, Chest
, CommandBlock
, Comparator
, Conduit
, Container
, CreatureSpawner
, DaylightDetector
, Dispenser
, Dropper
, EnchantingTable
, EnderChest
, EndGateway
, FlowerPot
, Furnace
, Hopper
, Jigsaw
, Jukebox
, Lectern
, NoteBlock
, ShulkerBox
, Sign
, Skull
, Smoker
, Structure
, TileState
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 | Description |
---|---|---|
Block |
getBlock() |
Gets the block represented by this block state.
|
BlockData |
getBlockData() |
Gets the data for this block state.
|
Chunk |
getChunk() |
Gets the chunk which contains the block represented by this block state.
|
MaterialData |
getData() |
Gets the metadata for this block state.
|
byte |
getLightLevel() |
Gets the current light level of the block represented by this block state.
|
Location |
getLocation() |
Gets the location of this block state.
|
Location |
getLocation(Location loc) |
Stores the location of this block state in the provided Location object.
|
byte |
getRawData() |
Deprecated.
Magic value
|
Material |
getType() |
Gets the type of this block state.
|
World |
getWorld() |
Gets the world which contains the block represented by this block state.
|
int |
getX() |
Gets the x-coordinate of this block state.
|
int |
getY() |
Gets the y-coordinate of this block state.
|
int |
getZ() |
Gets the z-coordinate of this block state.
|
boolean |
isPlaced() |
Returns whether this state is placed in the world.
|
void |
setBlockData(BlockData data) |
Sets the data for this block state.
|
void |
setData(MaterialData data) |
Sets the metadata for this block state.
|
void |
setRawData(byte data) |
Deprecated.
Magic value
|
void |
setType(Material type) |
Sets the type of this block state.
|
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
@NotNull Block getBlock()
IllegalStateException
- if this block state is not placed@NotNull MaterialData getData()
@NotNull BlockData getBlockData()
@NotNull Material getType()
byte getLightLevel()
IllegalStateException
- if this block state is not placed@NotNull World getWorld()
IllegalStateException
- if this block state is not placedint getX()
int getY()
int getZ()
@NotNull Location getLocation()
If this block state is not placed the location's world will be null!
@Contract("null -> null; !null -> !null") @Nullable Location getLocation(@Nullable Location loc)
If the provided Location is null this method does nothing and returns null.
If this block state is not placed the location's world will be null!
loc
- the location to copy into@NotNull Chunk getChunk()
IllegalStateException
- if this block state is not placedvoid setData(@NotNull MaterialData data)
data
- New block specific metadatavoid setBlockData(@NotNull BlockData data)
data
- New block specific datavoid setType(@NotNull Material type)
type
- Material to change this block state 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)
If this state is not placed, this will have no effect and return true.
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()
Some methods will not work if the block state isn't placed in the world.
Copyright © 2019. All rights reserved.