程序包 org.bukkit.block

接口 Block

所有超级接口:
Metadatable

public interface Block extends Metadatable
代表方块. 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.
  • 方法详细资料

    • getData

      @Deprecated byte getData()
      已过时。
      不安全的参数
      获取此方块的元数据.

      原文:Gets the metadata for this block

      返回:
      方块元数据
    • getRelative

      Block getRelative(int modX, int modY, int modZ)
      以指定坐标偏移量获取方块 (相对与方块位置的偏移量).

      原文:Gets the block at the given offsets

      参数:
      modX - X坐标偏移量
      modY - Y坐标偏移量
      modZ - Z坐标偏移量
      返回:
      在此坐标偏移量的方块
    • getRelative

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

      This method is equal to getRelative(face, 1)

      参数:
      face - Face of this block to return
      返回:
      Block at the given face
      另请参阅:
    • 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);
       
      参数:
      face - Face of this block to return
      distance - Distance to get the block at
      返回:
      Block at the given face
    • getType

      Material getType()
      获取此方块的种类.

      原文:Gets the type of this block

      返回:
      方块种类
    • getTypeId

      @Deprecated int getTypeId()
      已过时。
      不安全的参数
      获取此方块的种类ID.

      原文:Gets the type-id of this block

      返回:
      方块种类ID
    • getLightLevel

      byte getLightLevel()
      获取此方块的光亮等级,范围0~15.

      原文:Gets the light level between 0-15

      返回:
      光亮等级
    • 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.

      返回:
      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.

      返回:
      Block light level
    • getWorld

      World getWorld()
      获取此方块所处的世界.

      原文:Gets the world which contains this Block

      返回:
      方块所处的世界
    • getX

      int getX()
      获取此方块的X坐标.

      原文:Gets the x-coordinate of this block

      返回:
      X坐标
    • getY

      int getY()
      获取此方块的Y坐标.

      原文:Gets the y-coordinate of this block

      返回:
      Y坐标
    • getZ

      int getZ()
      获取此方块的Z坐标.

      原文:Gets the z-coordinate of this block

      返回:
      Z坐标
    • getLocation

      Location getLocation()
      获取方块的位置信息.

      原文:Gets the Location of the 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.

      参数:
      loc - the location to copy into
      返回:
      The Location object provided or null
    • getChunk

      Chunk getChunk()
      获取包含此方块的区块(方块所在的区块).

      原文:Gets the chunk which contains this block

      返回:
      包含此方块的区块
    • setData

      @Deprecated void setData(byte data)
      已过时。
      不安全的参数
      为这个方块设置元数据.

      原文:Sets the metadata for this block

      参数:
      data - 元数据
    • setData

      @Deprecated void setData(byte data, boolean applyPhysics)
      已过时。
      不安全的参数
      为这个方块设置元数据.

      原文:Sets the metadata for this block

      参数:
      data - 元数据
      applyPhysics - False to cancel physics from the changed block.
    • setType

      void setType(Material type)
      设置这个方块的类型.

      原文:Sets the type of this block

      参数:
      type - 方块的Material类型
    • setType

      void setType(Material type, boolean applyPhysics)
      Sets the type of this block
      参数:
      type - Material to change this block to
      applyPhysics - False to cancel physics on the changed block.
    • setTypeId

      @Deprecated boolean setTypeId(int type)
      已过时。
      Magic value
      Sets the type-id of this block
      参数:
      type - Type-Id to change this block to
      返回:
      whether the block was changed
    • setTypeId

      @Deprecated boolean setTypeId(int type, boolean applyPhysics)
      已过时。
      Magic value
      Sets the type-id of this block
      参数:
      type - Type-Id to change this block to
      applyPhysics - False to cancel physics on the changed block.
      返回:
      whether the block was changed
    • setTypeIdAndData

      @Deprecated boolean setTypeIdAndData(int type, byte data, boolean applyPhysics)
      已过时。
      Magic value
      Sets the type-id of this block
      参数:
      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
      返回:
      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
      参数:
      block - Block to compare against this block
      返回:
      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.

      返回:
      BlockState with the current state of this block.
    • getBiome

      Biome getBiome()
      Returns the biome that this block resides in
      返回:
      Biome type containing this block
    • setBiome

      void setBiome(Biome bio)
      Sets the biome that this block resides in
      参数:
      bio - new Biome type for this block
    • isBlockPowered

      boolean isBlockPowered()
      Returns true if the block is being powered by Redstone.
      返回:
      True if the block is powered.
    • isBlockIndirectlyPowered

      boolean isBlockIndirectlyPowered()
      Returns true if the block is being indirectly powered by Redstone.
      返回:
      True if the block is indirectly powered.
    • isBlockFacePowered

      boolean isBlockFacePowered(BlockFace face)
      Returns true if the block face is being powered by Redstone.
      参数:
      face - The block face
      返回:
      True if the block face is powered.
    • isBlockFaceIndirectlyPowered

      boolean isBlockFaceIndirectlyPowered(BlockFace face)
      Returns true if the block face is being indirectly powered by Redstone.
      参数:
      face - The block face
      返回:
      True if the block face is indirectly powered.
    • getBlockPower

      int getBlockPower(BlockFace face)
      Returns the redstone power being provided to this block face
      参数:
      face - the face of the block to query or BlockFace.SELF for the block itself
      返回:
      The power level.
    • getBlockPower

      int getBlockPower()
      Returns the redstone power being provided to this block
      返回:
      The power level.
    • isEmpty

      boolean isEmpty()
      Checks if this block is empty.

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

      返回:
      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.

      返回:
      true if this block is liquid
    • getTemperature

      double getTemperature()
      Gets the temperature of the biome of this block
      返回:
      Temperature of this block
    • getHumidity

      double getHumidity()
      Gets the humidity of the biome of this block
      返回:
      Humidity of this block
    • getPistonMoveReaction

      PistonMoveReaction getPistonMoveReaction()
      Returns the reaction of the block when moved by a piston
      返回:
      reaction
    • breakNaturally

      boolean breakNaturally()
      Breaks the block and spawns items as if a player had digged it
      返回:
      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
      参数:
      tool - The tool or item in hand used for digging
      返回:
      true if the block was destroyed
    • getDrops

      Collection<ItemStack> getDrops()
      Returns a list of items which would drop by destroying this block
      返回:
      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
      参数:
      tool - The tool or item in hand used for digging
      返回:
      a list of dropped items for this type of block