Interface BlockData
- All Superinterfaces:
Cloneable
- All Known Subinterfaces:
Ageable
,AmethystCluster
,AnaloguePowerable
,Attachable
,Bamboo
,Barrel
,Bed
,Beehive
,Bell
,BigDripleaf
,Bisected
,BrewingStand
,Brushable
,BubbleColumn
,Cake
,CalibratedSculkSensor
,Campfire
,Candle
,CaveVines
,CaveVinesPlant
,Chain
,Chest
,ChiseledBookshelf
,Cocoa
,CommandBlock
,Comparator
,CopperBulb
,CoralWallFan
,Crafter
,DaylightDetector
,DecoratedPot
,Directional
,Dispenser
,Door
,Dripleaf
,EnderChest
,EndPortalFrame
,FaceAttachable
,Farmland
,Fence
,Fire
,Furnace
,Gate
,GlassPane
,GlowLichen
,Grindstone
,Hangable
,HangingSign
,Hatchable
,Hopper
,Jigsaw
,Jukebox
,Ladder
,Lantern
,Leaves
,Lectern
,Levelled
,Light
,Lightable
,LightningRod
,MangrovePropagule
,MultipleFacing
,NoteBlock
,Observer
,Openable
,Orientable
,PinkPetals
,Piston
,PistonHead
,PitcherCrop
,PointedDripstone
,Powerable
,Rail
,RedstoneRail
,RedstoneWallTorch
,RedstoneWire
,Repeater
,RespawnAnchor
,Rotatable
,Sapling
,Scaffolding
,SculkCatalyst
,SculkSensor
,SculkShrieker
,SculkVein
,SeaPickle
,Sign
,Skull
,Slab
,SmallDripleaf
,Snow
,Snowable
,Stairs
,StructureBlock
,Switch
,TechnicalPiston
,TNT
,TrapDoor
,TrialSpawner
,Tripwire
,TripwireHook
,TurtleEgg
,Vault
,Wall
,WallHangingSign
,WallSign
,WallSkull
,Waterlogged
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a copy of this BlockData.void
Copies all applicable properties from this BlockData to the provided BlockData.Creates a new defaultBlockState
for this type of Block, not bound to a location.Gets a string, which when passed into a method such asServer.createBlockData(java.lang.String)
will unambiguously recreate this instance.getAsString
(boolean hideUnspecified) Gets a string, which when passed into a method such asServer.createBlockData(java.lang.String)
will recreate this or a similar instance where unspecified states (if any) may be optionally omitted.getCollisionShape
(@NotNull Location location) Calculates the collision shape this block data would have at a particular location.default float
getDestroySpeed
(@NotNull ItemStack itemStack) Gets the speed at which this block will be destroyed by a givenItemStack
float
getDestroySpeed
(@NotNull ItemStack itemStack, boolean considerEnchants) Gets the speed at which this block will be destroyed by a givenItemStack
int
Get the amount of light emitted by this state when in the world.Gets the color this block should appear as when rendered on a map.Get the Material represented by this block data.Returns the reaction of the block when moved by a pistonGets the material that a player would use to place this block.Gets the block'sSoundGroup
which can be used to get its step sound, hit sound, and others.boolean
isFaceSturdy
(@NotNull BlockFace face, @NotNull BlockSupport support) Checks if a state'sBlockFace
is capable of providing a given level ofBlockSupport
for neighbouring block states.boolean
Check whether or not this state will occlude other blocks.boolean
isPreferredTool
(@NotNull ItemStack tool) Returns if the given item is a preferred choice to break this Block.boolean
Gets if this block is ticked randomly in the world.boolean
isSupported
(@NotNull Location location) Checks if this state would be properly supported if it were placed at the block at the givenLocation
.boolean
isSupported
(@NotNull Block block) Checks if this state would be properly supported if it were placed at the givenBlock
.boolean
Checks if the specified BlockData matches this block data.Merges all explicitly set states from the given data with this BlockData.void
Mirrors this blockdata using the specifiedMirror
.boolean
Check whether or not this state requires a specific item to be used to drop items when broken.void
rotate
(@NotNull StructureRotation rotation) Rotates this blockdata by the specifiedStructureRotation
.
-
Method Details
-
getMaterial
Get the Material represented by this block data.- Returns:
- the material
-
getAsString
Gets a string, which when passed into a method such asServer.createBlockData(java.lang.String)
will unambiguously recreate this instance.- Returns:
- serialized data string for this block
-
getAsString
Gets a string, which when passed into a method such asServer.createBlockData(java.lang.String)
will recreate this or a similar instance where unspecified states (if any) may be optionally omitted. If this instance was parsed and states are omitted, this exact instance will be creatable when parsed again, else their equality cannot be guaranteed.This method will only take effect for BlockData instances created by methods such as
Server.createBlockData(String)
or any similar method whereby states are optionally defined. If otherwise, the result ofgetAsString()
will be returned. The following behaviour would be expected:String dataString = "minecraft:chest[waterlogged=true]" BlockData data = Bukkit.createBlockData(dataString); dataString.equals(data.getAsString(true)); // This would return true dataString.equals(data.getAsString(false)); // This would return false as all states are present dataString.equals(data.getAsString()); // This is equivalent to the above, "getAsString(false)"
- Parameters:
hideUnspecified
- true if unspecified states should be omitted, false if they are to be shown as performed bygetAsString()
.- Returns:
- serialized data string for this block
-
merge
Merges all explicitly set states from the given data with this BlockData.
Note that the given data MUST have been created from one of the String parse methods, e.g.Server.createBlockData(java.lang.String)
and not have been subsequently modified.
Note also that the block types must match identically.- Parameters:
data
- the data to merge from- Returns:
- a new instance of this blockdata with the merged data
-
matches
Checks if the specified BlockData matches this block data.
The semantics of this method are such that for manually created or modified BlockData it has the same effect asObject.equals(java.lang.Object)
, whilst for parsed data (that to whichmerge(org.bukkit.block.data.BlockData)
applies, it will return true when the type and all explicitly set states match.
Note that these semantics mean that a.matches(b) may not be the same as b.matches(a)- Parameters:
data
- the data to match against (normally a parsed constant)- Returns:
- if there is a match
-
clone
Returns a copy of this BlockData.- Returns:
- a copy of the block data
-
getSoundGroup
Gets the block'sSoundGroup
which can be used to get its step sound, hit sound, and others.- Returns:
- the sound effect group
-
getLightEmission
int getLightEmission()Get the amount of light emitted by this state when in the world.- Returns:
- the light emission
-
isOccluding
boolean isOccluding()Check whether or not this state will occlude other blocks.Block state occlusion affects visual features of other blocks (e.g. leaves and wet sponges will not spawn dripping water particles if an occluding state is below it), or whether light will pass through it.
- Returns:
- true if occluding, false otherwise
-
requiresCorrectToolForDrops
boolean requiresCorrectToolForDrops()Check whether or not this state requires a specific item to be used to drop items when broken. For example, diamond ore requires an iron pickaxe and will not drop diamonds when broken with a wooden or stone pickaxe.- Returns:
- true if a more specific item is required for drops, false if any item (or an empty hand) will drop items
-
isPreferredTool
Returns if the given item is a preferred choice to break this Block. In some cases this determines if a block will drop anything or extra loot.- Parameters:
tool
- The tool or item used for breaking this block- Returns:
- true if the tool is preferred for breaking this block.
-
getPistonMoveReaction
Returns the reaction of the block when moved by a piston- Returns:
- reaction
-
isSupported
Checks if this state would be properly supported if it were placed at the givenBlock
.This may be useful, for instance, to check whether or not a wall torch is capable of surviving on its neighbouring block states.
- Parameters:
block
- the block position at which the state would be placed- Returns:
- true if the block is supported, false if this state would not survive the world conditions
-
isSupported
Checks if this state would be properly supported if it were placed at the block at the givenLocation
.This may be useful, for instance, to check whether or not a wall torch is capable of surviving on its neighbouring block states.
- Parameters:
location
- the location at which the state would be placed- Returns:
- true if the block is supported, false if this state would not survive the world conditions
-
isFaceSturdy
Checks if a state'sBlockFace
is capable of providing a given level ofBlockSupport
for neighbouring block states.Any given state may support either none, one, or more than one level of block support depending on its states. A common example would be a wall's ability to support torches only on the center of the upper block face, whereas a grass block would support all levels of block support on all block faces.
- Parameters:
face
- the face to checksupport
- the possible support level- Returns:
- true if the face is sturdy and can support a block, false otherwise
-
getCollisionShape
Calculates the collision shape this block data would have at a particular location.This does not take into account any block updates that may occur if the block was to be actually placed in the world.
- Parameters:
location
- the location to calculate the collision shape at- Returns:
- a
VoxelShape
representing the collision shape of this block data.
-
getMapColor
Gets the color this block should appear as when rendered on a map.- Returns:
- the color associated with this BlockData
-
getPlacementMaterial
Gets the material that a player would use to place this block.For most blocks this is the same as
getMaterial()
but some blocks have different materials used to place them. For example:Material.REDSTONE_WIRE
->Material.REDSTONE
Material.CARROTS
->Material.CARROT
- Returns:
- placement material or
Material.AIR
if it doesn't have one
-
rotate
Rotates this blockdata by the specifiedStructureRotation
.This has no effect on blocks that do not have any rotatable states.
- Parameters:
rotation
- the rotation
-
mirror
Mirrors this blockdata using the specifiedMirror
.This has no effect on blocks that do not have any mirrorable states.
- Parameters:
mirror
- the mirror
-
copyTo
Copies all applicable properties from this BlockData to the provided BlockData.Only modifies properties that both blocks share in common.
- Parameters:
other
- the BlockData to copy properties to
-
createBlockState
Creates a new defaultBlockState
for this type of Block, not bound to a location.- Returns:
- a new
BlockState
-
getDestroySpeed
Gets the speed at which this block will be destroyed by a givenItemStack
Default value is 1.0
-
getDestroySpeed
Gets the speed at which this block will be destroyed by a givenItemStack
Default value is 1.0
- Parameters:
itemStack
-ItemStack
used to mine this BlockconsiderEnchants
- true to look at enchants on the itemstack- Returns:
- the speed that this Block will be mined by the given
ItemStack
- API Note:
- this method assumes default player state and hence, e.g., does not take into account changed player attributes or potion effects.
-
isRandomlyTicked
boolean isRandomlyTicked()Gets if this block is ticked randomly in the world. The blocks current state may change this value.- Returns:
- is ticked randomly
-