接口 BlockData
- 所有超级接口:
Cloneable
- 所有已知子接口:
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
,Slab
,SmallDripleaf
,Snow
,Snowable
,Stairs
,StructureBlock
,Switch
,TechnicalPiston
,TNT
,TrapDoor
,TrialSpawner
,Tripwire
,TripwireHook
,TurtleEgg
,Vault
,Wall
,WallHangingSign
,WallSign
,Waterlogged
-
方法概要
修饰符和类型方法说明clone()
返回该 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.获取方块数据值, 当将此数据值传入给Server.createBlockData(java.lang.String)
方法时, 将无缝重建此实例.getAsString
(boolean hideUnspecified) 获取一个字符串, 在传入类似于Server.createBlockData(java.lang.String)
的方法时可以重建此实例或与此实例相似的一个新实例, 但未被指定的数据值可以选择性的省略.int
获取此状态下的方块在世界中发出的光照强度。Gets the color this block should appear as when rendered on a map.获取该 BlockData 实例描述的物品.返回方块被活塞推动时的反应。获取玩家放置此方块所使用的物品材质。获取方块的SoundGroup
,可以用它来获取其行走声音、击打声音等其它声音。boolean
isFaceSturdy
(@NotNull BlockFace face, @NotNull BlockSupport support) 检查状态的BlockFace
是否能够为相邻的方块状态提供特定级别的BlockSupport
。boolean
检查此状态下的方块是否会遮挡其他方块。boolean
isPreferredTool
(@NotNull ItemStack tool) 返回给定物品是否为破坏此方块的首选选择。boolean
isSupported
(@NotNull Block block) 检查如果此状态下的方块放置在给定的方块
上,它是否会被正常支撑。boolean
isSupported
(@NotNull Location location) 检查如果此状态下的方块放置在给定的Location
的方块上,它是否会被正常支撑。boolean
判断给定 BlockData 数据与当前方块数据是否相同.将此 BlockData 中的数据与给定数据中所有明确数据合并.void
使用指定的Mirror
镜像此方块数据。boolean
检查是否需要使用特定物品才能掉落其物品。void
rotate
(@NotNull StructureRotation rotation) 使用指定的StructureRotation
旋转此方块数据。
-
方法详细资料
-
getMaterial
获取该 BlockData 实例描述的物品.原文: Get the Material represented by this block data.
- 返回:
- 物品
-
getAsString
获取方块数据值, 当将此数据值传入给Server.createBlockData(java.lang.String)
方法时, 将无缝重建此实例.原文: Gets a string, which when passed into a method such as
Server.createBlockData(java.lang.String)
will unambiguously recreate this instance.- 返回:
- 方块序列化的数据值
-
getAsString
获取一个字符串, 在传入类似于Server.createBlockData(java.lang.String)
的方法时可以重建此实例或与此实例相似的一个新实例, 但未被指定的数据值可以选择性的省略. 如果该实例已经被解析且有数据值被省略, 那么再次解析 (字符串) 时就可以创建一个 (与该实例) 一模一样的准确实例, 否则就不能保证新实例与旧实例相等 (equal).该方法仅对由
Server.createBlockData(String)
等方法 或其他任何数据值被有选择地赋值而创建的 BlockData 实例有效. 若非此情况, 将会返回getAsString()
方法的执行结果. 预期结果如下:String dataString = "minecraft:chest[waterlogged=true]" BlockData data = Bukkit.createBlockData(dataString); dataString.equals(data.getAsString(true)); // 将会返回 true dataString.equals(data.getAsString(false)); // 在所有数据值都被赋值的情况下会返回 false dataString.equals(data.getAsString()); // 与上一条语句等价, "getAsString(false)"
原文: Gets a string, which when passed into a method such as
Server.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)"
- 参数:
hideUnspecified
- 为 true 时未指定的数据值将会被省略, 为 false 时未指定的数据值也会被编入字符串, 与getAsString()
方法的执行结果一样.- 返回:
- 关于此方块的序列化数据字符串
-
merge
将此 BlockData 中的数据与给定数据中所有明确数据合并.译注: 这里的明确不明确应该是指有具体值的, 被赋值的是明确的.
请注意传入的数据 必须 是由某一种字符串解析方法产生的实例, 例如Server.createBlockData(java.lang.String)
, 且没有被修改过.
也要注意两个 BlockData 的方块类型也要相匹配.原文: 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.- 参数:
data
- 合并数据来源- 返回:
- 该方块数据与指定数据合并后的新 BlockData 实例
-
matches
判断给定 BlockData 数据与当前方块数据是否相同.
对于手动创建或修改过的 BlockData, 该方法在语义上与Object.equals(java.lang.Object)
方法效果一致, 而对于已解析的数据 (由merge(org.bukkit.block.data.BlockData)
方法应用产生的), 该方法仅在方块类型和所有明确数据值相匹配时返回 true.
请注意 a.matches(b) 与 b.matches(a) 的含义可能不相同原文: 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)- 参数:
data
- 需要判断相同的数据 (通常是一个常量解析出来的)- 返回:
- 若两者相匹配返回 true
-
clone
返回该 BlockData 实例的副本.原文: Returns a copy of this BlockData.
- 返回:
- BlockData 副本
-
getSoundGroup
获取方块的SoundGroup
,可以用它来获取其行走声音、击打声音等其它声音。原文: Gets the block's
SoundGroup
which can be used to get its step sound, hit sound, and others.- 返回:
- 音效组
-
getLightEmission
int getLightEmission()获取此状态下的方块在世界中发出的光照强度。原文: Get the amount of light emitted by this state when in the world.
- 返回:
- 光照强度
-
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.
- 返回:
- 如果会遮挡其它方块为true, 否则为 false
-
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.
- 返回:
- 如果需要一种或多种特定物品才能掉落物品则为true, 如果任意物品(或空手)即可掉落物品则为 false
-
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.
- 参数:
tool
- 用于破坏此方块的工具或物品- 返回:
- 如果此工具是破坏此方块的首选选择则为 true.
-
getPistonMoveReaction
返回方块被活塞推动时的反应。原文: Returns the reaction of the block when moved by a piston
- 返回:
- reaction 反应
-
isSupported
检查如果此状态下的方块放置在给定的方块
上,它是否会被正常支撑。例如,这可能有用来检查壁式火炬是否能够在其相邻的方块状态上存活。
原文: Checks if this state would be properly supported if it were placed at the given
Block
.This may be useful, for instance, to check whether or not a wall torch is capable of surviving on its neighbouring block states.
- 参数:
block
- 此方块要放置在哪个方块上- 返回:
- 如果此方块可被支撑则为 true, 如果此状态下的方块无法在此世界的状况下留存则为 false
-
isSupported
检查如果此状态下的方块放置在给定的Location
的方块上,它是否会被正常支撑。例如,这可能有用来检查壁式火炬是否能够在其相邻的方块状态上存活。
原文: Checks if this state would be properly supported if it were placed at the block at the given
Location
.This may be useful, for instance, to check whether or not a wall torch is capable of surviving on its neighbouring block states.
- 参数:
location
- 此方块要放置在哪个位置上- 返回:
- 如果此方块可被支撑则为 true, 如果此状态下的方块无法在此世界的状况下留存则为 false
-
isFaceSturdy
检查状态的BlockFace
是否能够为相邻的方块状态提供特定级别的BlockSupport
。任何给定状态都可以根据其状态支持零、一个或多个支撑级别。一个常见的例子是墙只能在上表面中心支撑火把,而草方块则在所有表面支持所有支撑级别。
原文: Checks if a state's
BlockFace
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.
- 参数:
face
- 要检测的面support
- 可能的支撑级别- 返回:
- 如果这一面足够牢固并可支撑此方块则为 true, 否则为 false
-
getMapColor
Gets the color this block should appear as when rendered on a map.- 返回:
- the color associated with this BlockData
-
getPlacementMaterial
获取玩家放置此方块所使用的物品材质。对于大多数方块,这与
getMaterial()
相同,但有些方块有不同的材质用于放置它们。例如:
Material.REDSTONE_WIRE
->Material.REDSTONE
Material.CARROTS
->Material.CARROT
原文: 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
- 返回:
- 放置此方块所使用的物品材质
-
rotate
使用指定的StructureRotation
旋转此方块数据。这对于没有可旋转状态的方块没有影响。
原文: Rotates this blockdata by the specified
StructureRotation
.This has no effect on blocks that do not have any rotatable states.
- 参数:
rotation
- 旋转角度
-
mirror
使用指定的Mirror
镜像此方块数据。这对于没有可镜像状态的方块没有影响。
原文: Mirrors this blockdata using the specified
Mirror
.This has no effect on blocks that do not have any mirrorable states.
- 参数:
mirror
- 镜像
-
copyTo
Copies all applicable properties from this BlockData to the provided BlockData.Only modifies properties that both blocks share in common.
- 参数:
other
- the BlockData to copy properties to
-
createBlockState
Creates a new defaultBlockState
for this type of Block, not bound to a location.- 返回:
- a new
BlockState
-