跳到主要内容

BlockAPI

通过 BlockAPI.API 访问。提供方块设置与方块发包能力。

方法列表

设置方块

方法签名说明
setBlock(location: Location, type: Material, face: BlockFace?)在指定位置设置方块,可选朝向
setBlock(locations: List<Location>, type: Material, face: BlockFace?)批量设置方块
import kim.hhhhhy.kethermodule.api.BlockAPI
import org.bukkit.Material
import org.bukkit.block.BlockFace

// 单个方块
BlockAPI.API.setBlock(location, Material.CHEST, BlockFace.NORTH)

// 不指定朝向
BlockAPI.API.setBlock(location, Material.STONE, null)

// 批量设置
BlockAPI.API.setBlock(locationList, Material.BARRIER, null)

方块发包

方块发包仅对指定玩家发送视觉效果,不会修改服务端实际方块数据。

方法签名说明
sendBlockPacket(player: Player, location: Location, material: Material, data: Int)向玩家发送方块发包
sendFallingBlockPacket(player: Player, location: Location, material: Material, data: Int, toSolid: Boolean)向玩家发送下落方块发包

参数说明:

参数类型说明
playerPlayer目标玩家
locationLocation方块位置
materialMaterial方块材质
dataInt方块附加数据(BlockData)
toSolidBoolean下落方块落地后是否转为实体方块
import kim.hhhhhy.kethermodule.api.BlockAPI

// 发送方块发包
BlockAPI.API.sendBlockPacket(player, location, Material.DIAMOND_BLOCK, 0)

// 发送下落方块发包,落地后转为实体方块
BlockAPI.API.sendFallingBlockPacket(player, location, Material.SAND, 0, true)