程序包 org.bukkit.block

接口 BlockState

所有超级接口:
Metadatable
所有已知子接口:
Banner, Beacon, Bed, BrewingStand, Chest, CommandBlock, Comparator, Container, CreatureSpawner, DaylightDetector, Dispenser, Dropper, EnchantingTable, EnderChest, EndGateway, FlowerPot, Furnace, Hopper, Jukebox, NoteBlock, ShulkerBox, Sign, Skull, Structure

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.

  • 方法概要

    修饰符和类型
    方法
    说明
    Gets the block represented by this block state.
    Gets the chunk which contains the block represented by this block state.
    Gets the metadata for this block state.
    byte
    Gets the current light level of the block represented by this block state.
    Gets the location of this block state.
    Stores the location of this block state in the provided Location object.
    byte
    已过时。
    Magic value
    Gets the type of this block state.
    int
    已过时。
    Magic value
    Gets the world which contains the block represented by this block state.
    int
    Gets the x-coordinate of this block state.
    int
    Gets the y-coordinate of this block state.
    int
    Gets the z-coordinate of this block state.
    boolean
    Returns whether this state is placed in the world.
    void
    Sets the metadata for this block state.
    void
    setRawData(byte data)
    已过时。
    Magic value
    void
    Sets the type of this block state.
    boolean
    setTypeId(int type)
    已过时。
    Magic value
    boolean
    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.

    从接口继承的方法 org.bukkit.metadata.Metadatable

    getMetadata, hasMetadata, removeMetadata, setMetadata
  • 方法详细资料

    • getBlock

      Block getBlock()
      Gets the block represented by this block state.
      返回:
      the block represented by this block state
      抛出:
      IllegalStateException - if this block state is not placed
    • getData

      MaterialData getData()
      Gets the metadata for this block state.
      返回:
      block specific metadata
    • getType

      Material getType()
      Gets the type of this block state.
      返回:
      block type
    • getTypeId

      @Deprecated int getTypeId()
      已过时。
      Magic value
      Gets the type-id of this block state.
      返回:
      block type-id
    • getLightLevel

      byte getLightLevel()
      Gets the current light level of the block represented by this block state.
      返回:
      the light level between 0-15
      抛出:
      IllegalStateException - if this block state is not placed
    • getWorld

      World getWorld()
      Gets the world which contains the block represented by this block state.
      返回:
      the world containing the block represented by this block state
      抛出:
      IllegalStateException - if this block state is not placed
    • getX

      int getX()
      Gets the x-coordinate of this block state.
      返回:
      x-coordinate
    • getY

      int getY()
      Gets the y-coordinate of this block state.
      返回:
      y-coordinate
    • getZ

      int getZ()
      Gets the z-coordinate of this block state.
      返回:
      z-coordinate
    • getLocation

      Location getLocation()
      Gets the location of this block state.

      If this block state is not placed the location's world will be null!

      返回:
      the location
    • getLocation

      Location getLocation(Location loc)
      Stores the location of this block state in the provided Location object.

      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
      返回:
      The Location object provided or null
    • getChunk

      Chunk getChunk()
      Gets the chunk which contains the block represented by this block state.
      返回:
      the containing Chunk
      抛出:
      IllegalStateException - if this block state is not placed
    • setData

      void setData(MaterialData data)
      Sets the metadata for this block state.
      参数:
      data - New block specific metadata
    • setType

      void setType(Material type)
      Sets the type of this block state.
      参数:
      type - Material to change this block state to
    • setTypeId

      @Deprecated boolean setTypeId(int type)
      已过时。
      Magic value
      Sets the type-id of this block state.
      参数:
      type - Type-Id to change this block state to
      返回:
      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.

      返回:
      true if the update was successful, otherwise false
      另请参阅:
    • 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.

      参数:
      force - true to forcefully set the state
      返回:
      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.

      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 state
      applyPhysics - false to cancel updating physics on surrounding blocks
      返回:
      true if the update was successful, otherwise false
    • getRawData

      @Deprecated byte getRawData()
      已过时。
      Magic value
      返回:
      The data as a raw byte.
    • setRawData

      @Deprecated void setRawData(byte data)
      已过时。
      Magic value
      参数:
      data - The new data value for the block.
    • isPlaced

      boolean isPlaced()
      Returns whether this state is placed in the world.

      Some methods will not work if the block state isn't placed in the world.

      返回:
      whether the state is placed in the world or 'virtual' (e.g. on an itemstack)