Class XBlock
java.lang.Object
com.cryptomorin.xseries.XBlock
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
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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteDeprecated.Deprecated.UseXTag.DANGEROUS_BLOCKSinstead. -
Method Summary
Modifier and TypeMethodDescriptionstatic intaddCakeSlices(org.bukkit.block.Block block, int slices) static intgetAge(org.bukkit.block.Block block) static org.bukkit.DyeColorgetColor(org.bukkit.block.Block block) Wool and Dye.static org.bukkit.block.BlockFacegetDirection(org.bukkit.block.Block block) static intgetFluidLevel(org.bukkit.block.Block block) static org.bukkit.block.BlockFacegetRotation(org.bukkit.block.Block block) static org.bukkit.SkullTypegetSkullType(XMaterial material) static XMaterialgetType(org.bukkit.block.Block block) Best attempt at guessing the correctXMaterialversion of a given block.static booleanisAir(@Nullable org.bukkit.Material material) static booleanisBeetroot(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisCake(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisCarrot(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisContainer(@Nullable org.bukkit.block.Block block) Checks if the block is a container.static booleanDeprecated.UseXTag.CROPSinstead.static booleanisDangerous(XMaterial material) Deprecated.UseXTag.DANGEROUS_BLOCKSinstead.static booleanisLava(org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisLit(org.bukkit.block.Block block) static booleanisMelon(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisNetherWart(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisOneOf(org.bukkit.block.Block block, Collection<String> blocks) Deprecated.useXTag.anyMatch(Object, Collection)instead.static booleanisOpen(org.bukkit.block.Block block) static booleanisPotato(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisPowered(org.bukkit.block.Block block) static booleanUniversal Method The difference between simply checkign the given material againstgetType(Block)and this is that this method is more lenient and will match materials even if their "state" are different.static booleanisSugarCane(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisWater(org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static booleanisWaterStationary(org.bukkit.block.Block block) static booleanisWheat(@Nullable org.bukkit.Material material) Deprecated.UseisSimilar(Block, XMaterial)instead.static voidsetAge(org.bukkit.block.Block block, int age) static voidsetCakeSlices(org.bukkit.block.Block block, int amount) static booleansetColor(org.bukkit.block.Block block, org.bukkit.DyeColor color) Sets the type of any block that can be colored.static booleansetDirection(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing) static voidsetEnderPearlOnFrame(org.bukkit.block.Block endPortalFrame, boolean eye) static booleansetFluidLevel(org.bukkit.block.Block block, int level) Can be used on cauldrons as well.static voidsetLit(org.bukkit.block.Block block, boolean lit) Can be furnaces or redstone lamps.static voidsetOpened(org.bukkit.block.Block block, boolean opened) static voidsetPowered(org.bukkit.block.Block block, boolean powered) static voidsetRotation(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing) static voidstatic voidNote: Special blocks such as beds that require two different blocks to handle will not be set correctly.
-
Field Details
-
CROPS
Deprecated.UseXTag.CROPSinstead.This list contains both block and item version of the same material. -
DANGEROUS
Deprecated.UseXTag.DANGEROUS_BLOCKSinstead. -
CAKE_SLICES
public static final byte CAKE_SLICES- See Also:
-
-
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.UseXTag.CROPSinstead.Any material that can be planted which is fromCROPS- Parameters:
material- the material to check.- Returns:
- true if this material is a crop, otherwise false.
-
isDangerous
Deprecated.UseXTag.DANGEROUS_BLOCKSinstead.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.UseisSimilar(Block, XMaterial)instead. -
isWheat
Deprecated.UseisSimilar(Block, XMaterial)instead. -
isSugarCane
Deprecated.UseisSimilar(Block, XMaterial)instead. -
isBeetroot
Deprecated.UseisSimilar(Block, XMaterial)instead. -
isNetherWart
Deprecated.UseisSimilar(Block, XMaterial)instead. -
isCarrot
Deprecated.UseisSimilar(Block, XMaterial)instead. -
isMelon
Deprecated.UseisSimilar(Block, XMaterial)instead. -
isPotato
Deprecated.UseisSimilar(Block, XMaterial)instead. -
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
-
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
-
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.UseisSimilar(Block, XMaterial)instead. -
isLava
Deprecated.UseisSimilar(Block, XMaterial)instead. -
isOneOf
Deprecated.useXTag.anyMatch(Object, Collection)instead. -
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
Universal Method The difference between simply checkign the given material againstgetType(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)
-
XTag.CROPSinstead.