用户:
Nysidla查看:0 回复:1 评论:0 创建时间:2023-05-14T19:39:43
world.onPress(async ({ button, entity, raycast, tick }) => {
if (button == "action1") {
if (entity.tick + 5 >= tick || entity.position.distance(raycast.hitPosition) >= 4) return//设定一个时间限制,以免出现一个方块减多个数量的情况
entity.tick = tick//更新
const pos = raycast.voxelIndex.add(raycast.normal)
const bounds = new Box3Bounds3(new Box3Vector3(pos.x, pos.y, pos.z), new Box3Vector3(pos.x + 1.2, pos.y + 1, pos.z + 1.2))
if (world.searchBox(bounds).length != 0) return
voxels.setVoxel(pos.x, pos.y, pos.z, 方块ID)
}
})
world.onPlayerJoin(async({entity})=>{
entity.tick = 0
})
适用于scale = 0.8。
这个时候有人就说了:
“啊作者作者,你这还是会卡啊”
笑喵,这玩意天天卡,加上这个就好了:
world.onTick(async ({ tick }) => {
world.querySelectorAll('player').filter(e => !e.destroyed || e.player.spectator == false).forEach((e) => {
if (voxels.getVoxel(e.position.x, e.position.y - 0.8, e.position.z) != 0 && e.setUp.team != '') {
e.position.y += 1
}
}
})
你浅看了一下,然后又说:
“啊作者作者,卡方块后加Y坐标干嘛啊”
管他呢,能用就行了。
最后,谢谢给我灵感和让我chao(借)xi(鉴)的那个人)(虽然记不起是谁了()