Package com.cryptomorin.xseries
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:
- 2.2.0
- Author:
- Crypto Morin
- See Also:
-
BlockBlockStateMaterialDataXMaterial
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAn enum with cached legacy materials which can be used when comparing blocks with blocks and blocks with items. -
Field Summary
Fields -
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 XMaterialgetType(org.bukkit.block.Block block) Deprecated.static booleanisAir(org.bukkit.Material material) static booleanisBeetroot(org.bukkit.Material material) static booleanisCake(org.bukkit.Material material) static booleanisCarrot(org.bukkit.Material material) static booleanisContainer(org.bukkit.block.Block block) Checks if the block is a container.static booleanAny material that can be planted which is fromCROPSstatic booleanisDangerous(XMaterial material) Any material that can damage players, usually by interacting with the block.static booleanisLava(org.bukkit.Material material) static booleanisLit(org.bukkit.block.Block block) static booleanisMelon(org.bukkit.Material material) static booleanisNetherWart(org.bukkit.Material material) static booleanisOneOf(org.bukkit.block.Block block, Collection<String> blocks) static booleanisOpen(org.bukkit.block.Block block) static booleanisPotato(org.bukkit.Material material) static booleanisPowered(org.bukkit.block.Block block) static booleanSame asisType(Block, XMaterial)except it also does a simpleXMaterial.matchXMaterial(Material)comparison with the given block and material.static booleanisSugarCane(org.bukkit.Material material) static booleanUniversal Methodstatic booleanisWater(org.bukkit.Material material) static booleanisWaterStationary(org.bukkit.block.Block block) static booleanisWheat(org.bukkit.Material material) 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 booleanstatic boolean
-
Field Details
-
CROPS
-
DANGEROUS
-
CAKE_SLICES
public static final byte CAKE_SLICES- See Also:
-
-
Method Details
-
isLit
public static boolean isLit(org.bukkit.block.Block block) -
isContainer
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
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
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
-
isWheat
-
isSugarCane
-
isBeetroot
-
isNetherWart
-
isCarrot
-
isMelon
-
isPotato
-
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) -
setType
-
setType
-
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
public static boolean isWater(org.bukkit.Material material) -
isLava
public static boolean isLava(org.bukkit.Material material) -
isOneOf
-
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) -
getType
Deprecated.Not stable, useisType(Block, XMaterial)orisSimilar(Block, XMaterial)instead. If you want to save a block material somewhere, you need to useXMaterial.matchXMaterial(Material)- Parameters:
block- the block to get its XMaterial type.- Returns:
- the XMaterial of the block.
-
isSimilar
Same asisType(Block, XMaterial)except it also does a simpleXMaterial.matchXMaterial(Material)comparison with the given block and material.- 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
- See Also:
-
isType
Universal MethodCheck if the block type matches the specified XMaterial. Note that this method assumes that you've already tried doing
XMaterial.matchXMaterial(Material)usingBlock.getType()and compared it with the other XMaterial. If not, useisSimilar(Block, XMaterial)- Parameters:
block- the block to check.material- the XMaterial similar to this block type.- Returns:
- true if the raw block type matches with the material.
- See Also:
-
isAir
-
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)
-
isType(Block, XMaterial)orisSimilar(Block, XMaterial)instead.