Class XBlock

java.lang.Object
com.cryptomorin.xseries.XBlock

public final class XBlock extends Object
XBlock - MaterialData/BlockData Support
BlockState (Old): https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/BlockState.html BlockData (New): https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/data/BlockData.html MaterialData (Old): https://hub.spigotmc.org/javadocs/spigot/org/bukkit/material/MaterialData.html

All the parameters are non-null except the ones marked as nullable. This class doesn't and shouldn't support materials that are Material.isLegacy().

Version:
4.1.0
Author:
Crypto Morin
See Also:
  • Field Details

  • Method Details

    • isLit

      public static boolean isLit(org.bukkit.block.Block block)
    • isContainer

      public static boolean isContainer(@Nullable @Nullable org.bukkit.block.Block block)
      Checks if the block is a container. Containers are chests, hoppers, enderchests and everything that has an inventory.
      Parameters:
      block - the block to check.
      Returns:
      true if the block is a container, otherwise false.
    • setLit

      public static void setLit(org.bukkit.block.Block block, boolean lit)
      Can be furnaces or redstone lamps.
      Parameters:
      block - the block to change.
      lit - if it should be lit or not.
    • isCrop

      @Deprecated public static boolean isCrop(XMaterial material)
      Deprecated.
      Use XTag.CROPS instead.
      Any material that can be planted which is from CROPS
      Parameters:
      material - the material to check.
      Returns:
      true if this material is a crop, otherwise false.
    • isDangerous

      @Deprecated public static boolean isDangerous(XMaterial material)
      Deprecated.
      Any material that can damage players, usually by interacting with the block.
      Parameters:
      material - the material to check.
      Returns:
      true if this material is dangerous, otherwise false.
    • getColor

      public static org.bukkit.DyeColor getColor(org.bukkit.block.Block block)
      Wool and Dye. But Dye is not a block itself.
    • isCake

      @Deprecated public static boolean isCake(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • isWheat

      @Deprecated public static boolean isWheat(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • isSugarCane

      @Deprecated public static boolean isSugarCane(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • isBeetroot

      @Deprecated public static boolean isBeetroot(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • isNetherWart

      @Deprecated public static boolean isNetherWart(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • isCarrot

      @Deprecated public static boolean isCarrot(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • isMelon

      @Deprecated public static boolean isMelon(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • isPotato

      @Deprecated public static boolean isPotato(@Nullable @Nullable org.bukkit.Material material)
      Deprecated.
    • getDirection

      public static org.bukkit.block.BlockFace getDirection(org.bukkit.block.Block block)
    • setDirection

      public static boolean setDirection(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing)
    • getType

      @Experimental public static XMaterial getType(org.bukkit.block.Block block)
      Best attempt at guessing the correct XMaterial version of a given block.
      Since:
      4.0.0
    • setType

      public static void setType(@NotNull @NotNull org.bukkit.block.Block block, @Nullable @Nullable XMaterial material, boolean applyPhysics)
      Note: Special blocks such as beds that require two different blocks to handle will not be set correctly. You'd have to manually set these blocks. (Double/tall plants work fine)
      Throws:
      XBlock.BlockTypeChangeException - due to several reasons (i.e. XBlock.BlockTypeChangeException.Reason)
    • getSkullType

      public static org.bukkit.SkullType getSkullType(XMaterial material)
    • setType

      public static void setType(@NotNull @NotNull org.bukkit.block.Block block, @Nullable @Nullable XMaterial material)
    • getAge

      public static int getAge(org.bukkit.block.Block block)
    • setAge

      public static void setAge(org.bukkit.block.Block block, int age)
    • setColor

      public static boolean setColor(org.bukkit.block.Block block, org.bukkit.DyeColor color)
      Sets the type of any block that can be colored.
      Parameters:
      block - the block to color.
      color - the color to use.
      Returns:
      true if the block can be colored, otherwise false.
    • setFluidLevel

      public static boolean setFluidLevel(org.bukkit.block.Block block, int level)
      Can be used on cauldrons as well.
      Parameters:
      block - the block to set the fluid level of.
      level - the level of fluid.
      Returns:
      true if this block can have a fluid level, otherwise false.
    • getFluidLevel

      public static int getFluidLevel(org.bukkit.block.Block block)
    • isWaterStationary

      public static boolean isWaterStationary(org.bukkit.block.Block block)
    • isWater

      @Deprecated public static boolean isWater(org.bukkit.Material material)
      Deprecated.
    • isLava

      @Deprecated public static boolean isLava(org.bukkit.Material material)
      Deprecated.
    • isOneOf

      @Deprecated public static boolean isOneOf(org.bukkit.block.Block block, Collection<String> blocks)
      Deprecated.
    • setCakeSlices

      public static void setCakeSlices(org.bukkit.block.Block block, int amount)
    • addCakeSlices

      public static int addCakeSlices(org.bukkit.block.Block block, int slices)
    • setEnderPearlOnFrame

      public static void setEnderPearlOnFrame(org.bukkit.block.Block endPortalFrame, boolean eye)
    • isSimilar

      public static boolean isSimilar(org.bukkit.block.Block block, XMaterial material)
      Universal Method The difference between simply checkign the given material against getType(Block) and this is that this method is more lenient and will match materials even if their "state" are different. This usually only happens in older versions where for example carrots and potatoes have two separate materials for blocks and items. Or for example growth state of crops are ignored and all "air" materials are treated the same.

      So use getType(Block) for more exact matches and use this method if you want to be more forgiving, which can be useful for configured values by server admins.

      Parameters:
      block - the block to compare.
      material - the material to compare with.
      Returns:
      true if block type is similar to the given material.
      Since:
      1.3.0
    • isAir

      public static boolean isAir(@Nullable @Nullable org.bukkit.Material material)
    • isPowered

      public static boolean isPowered(org.bukkit.block.Block block)
    • setPowered

      public static void setPowered(org.bukkit.block.Block block, boolean powered)
    • isOpen

      public static boolean isOpen(org.bukkit.block.Block block)
    • setOpened

      public static void setOpened(org.bukkit.block.Block block, boolean opened)
    • getRotation

      public static org.bukkit.block.BlockFace getRotation(org.bukkit.block.Block block)
    • setRotation

      public static void setRotation(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing)