Interface BlockCompat

All Known Implementing Classes:
NewBlockCompat

public interface BlockCompat
Methods which operate with blocks but are not compatible across some Minecraft versions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BlockCompat
    Instance of BlockCompat for current Minecraft version.
    static final BlockSetter
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable BlockValues
    createBlockValues(org.bukkit.Material type, Map<String,String> states)
    Creates new block values for given material and state.
    @Nullable BlockValues
    createBlockValues(org.bukkit.Material type, Map<String,String> states, @Nullable org.bukkit.inventory.ItemStack item, int itemFlags)
    Creates new block values for given material and state.
    org.bukkit.block.BlockState
    fallingBlockToState(org.bukkit.entity.FallingBlock entity)
    Creates a block state from a falling block.
    default @Nullable BlockValues
    getBlockValues(org.bukkit.block.Block block)
    Gets block values from a block.
    @Nullable BlockValues
    getBlockValues(org.bukkit.block.BlockState block)
    Gets block values from a block state.
    default @Nullable BlockValues
    getBlockValues(org.bukkit.entity.FallingBlock entity)
     
    @Nullable BlockValues
    getBlockValues(org.bukkit.inventory.ItemStack stack)
    Gets block values from a item stack.
    Gets block setter that understands block values produced by this compatibility layer.
    boolean
    isEmpty(org.bukkit.Material type)
    Checks whether the given material implies emptiness.
    boolean
    isLiquid(org.bukkit.Material type)
    Checks whether the given material is a liquid.
  • Field Details

    • INSTANCE

      static final BlockCompat INSTANCE
      Instance of BlockCompat for current Minecraft version.
    • SETTER

      static final BlockSetter SETTER
  • Method Details

    • getBlockValues

      @Nullable BlockValues getBlockValues(org.bukkit.block.BlockState block)
      Gets block values from a block state. They can be compared to other values if needed, but cannot be used to retrieve any other data.
      Parameters:
      block - Block state to retrieve value from.
      Returns:
      Block values.
    • getBlockValues

      default @Nullable BlockValues getBlockValues(org.bukkit.block.Block block)
      Gets block values from a block. They can be compared to other values if needed, but cannot be used to retrieve any other data.
      Parameters:
      block - Block to retrieve value from.
      Returns:
      Block values.
    • getBlockValues

      @Nullable BlockValues getBlockValues(org.bukkit.inventory.ItemStack stack)
      Gets block values from a item stack. They can be compared to other values if needed, but cannot be used to retrieve any other data.
      Parameters:
      stack - Item that would be placed as the block
      Returns:
      Block values.
    • fallingBlockToState

      org.bukkit.block.BlockState fallingBlockToState(org.bukkit.entity.FallingBlock entity)
      Creates a block state from a falling block.
      Parameters:
      entity - Falling block entity
      Returns:
      Block state.
    • getBlockValues

      default @Nullable BlockValues getBlockValues(org.bukkit.entity.FallingBlock entity)
    • createBlockValues

      @Nullable BlockValues createBlockValues(org.bukkit.Material type, Map<String,String> states, @Nullable org.bukkit.inventory.ItemStack item, int itemFlags)
      Creates new block values for given material and state. Item, if given, will be used to correct data value etc. when needed.
      Parameters:
      type - Block material.
      states - Block states, as used in /setblock command in Minecraft.
      item - Item form that may or may not provide additional information. Optional, but very useful on 1.12 and older.
      itemFlags - Additional information about item. See ItemFlags.
      Returns:
      Block values, or null if given state was invalid.
    • createBlockValues

      default @Nullable BlockValues createBlockValues(org.bukkit.Material type, Map<String,String> states)
      Creates new block values for given material and state.
      Parameters:
      type - Block material.
      states - Block states, as used in /setblock command in Minecraft.
      Returns:
      Block values, or null if given state was invalid.
    • getSetter

      BlockSetter getSetter()
      Gets block setter that understands block values produced by this compatibility layer.
      Returns:
      Block setter.
    • isEmpty

      boolean isEmpty(org.bukkit.Material type)
      Checks whether the given material implies emptiness. On Minecraft 1.13+, there are several blocks that do so.
      Parameters:
      type - Material of block.
      Returns:
      Whether the material implies empty block.
    • isLiquid

      boolean isLiquid(org.bukkit.Material type)
      Checks whether the given material is a liquid.
      Parameters:
      type - Material of block.
      Returns:
      Whether the material is liquid.