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.1
- Author:
- Crypto Morin
- See Also:
-
Block
BlockState
MaterialData
XMaterial
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enum with cached legacy materials which can be used when comparing blocks with blocks and blocks with items. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
addCakeSlices
(org.bukkit.block.Block block, int slices) static int
getAge
(org.bukkit.block.Block block) static org.bukkit.DyeColor
getColor
(org.bukkit.block.Block block) Wool and Dye.static org.bukkit.block.BlockFace
getDirection
(org.bukkit.block.Block block) static int
getFluidLevel
(org.bukkit.block.Block block) static org.bukkit.block.BlockFace
getRotation
(org.bukkit.block.Block block) static XMaterial
getType
(org.bukkit.block.Block block) Deprecated.static boolean
isAir
(org.bukkit.Material material) static boolean
isBeetroot
(org.bukkit.Material material) static boolean
isCake
(org.bukkit.Material material) static boolean
isCarrot
(org.bukkit.Material material) static boolean
isContainer
(org.bukkit.block.Block block) Checks if the block is a container.static boolean
Any material that can be planted which is fromCROPS
static boolean
isDangerous
(XMaterial material) Any material that can damage players, usually by interacting with the block.static boolean
isLava
(org.bukkit.Material material) static boolean
isLit
(org.bukkit.block.Block block) static boolean
isMelon
(org.bukkit.Material material) static boolean
isNetherWart
(org.bukkit.Material material) static boolean
isOneOf
(org.bukkit.block.Block block, Collection<String> blocks) static boolean
isOpen
(org.bukkit.block.Block block) static boolean
isPotato
(org.bukkit.Material material) static boolean
isPowered
(org.bukkit.block.Block block) static boolean
Same asisType(Block, XMaterial)
except it also does a simpleXMaterial.matchXMaterial(Material)
comparison with the given block and material.static boolean
isSugarCane
(org.bukkit.Material material) static boolean
Universal Methodstatic boolean
isWater
(org.bukkit.Material material) static boolean
isWaterStationary
(org.bukkit.block.Block block) static boolean
isWheat
(org.bukkit.Material material) static void
setAge
(org.bukkit.block.Block block, int age) static void
setCakeSlices
(org.bukkit.block.Block block, int amount) static boolean
setColor
(org.bukkit.block.Block block, org.bukkit.DyeColor color) Sets the type of any block that can be colored.static boolean
setDirection
(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing) static void
setEnderPearlOnFrame
(org.bukkit.block.Block endPortalFrame, boolean eye) static boolean
setFluidLevel
(org.bukkit.block.Block block, int level) Can be used on cauldrons as well.static void
setLit
(org.bukkit.block.Block block, boolean lit) Can be furnaces or redstone lamps.static void
setOpened
(org.bukkit.block.Block block, boolean opened) static void
setPowered
(org.bukkit.block.Block block, boolean powered) static void
setRotation
(org.bukkit.block.Block block, org.bukkit.block.BlockFace facing) static boolean
static boolean
-
Field Details
-
CROPS
This list contains both block and item version of the same material. -
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.