用户:
ChenGe_12查看:0 回复:3 评论:0 创建时间:2023-08-20T20:24:29
world.onPress(async ({entity,button}) => {
if (button == 'action0') {
if (distance <= 3 && raycast.hitVoxel) {
//方块破坏
clicker.wjzb = raycast.voxelIndex//挖掘坐标
const wjzb = raycast.voxelIndex
for (let i = 0; i <= 0.8/*填入挖掘时间(秒)我用的0.8*/); i += 0.1) {
if (wjzb != clicker.wjzb)return;
if (clicker.player.dead == true)return;
await sleep(100)
}
voxels.setVoxelId(wjzb.x, wjzb.y, wjzb.z, 0)
}
};
});
world.onRelease(({entity,button})=>{
if(button == 'action0'){
//停止挖掘
entity.wjzb = null;
}
})
注:
1、老版新版通用
2、且注意原代码中的玩家实体不能含有标签 wjzb ,如果源代码中有则将代码中所有 wjzb 更名。
逍遥天启代码符号报错修改完是这样: world.onPress(async ({entity,button}) => { if (button == 'action0') { if (distance <= 3 && raycast.hitVoxel) { //方块破坏 clicker.wjzb = raycast.voxelIndex//挖掘坐标 const wjzb = raycast.voxelIndex for (let i = 0; i <= 0.8; i += 0.1) { if (wjzb != clicker.wjzb)return; if (clicker.player.dead == true)return; await sleep(100) } voxels.setVoxelId(wjzb.x, wjzb.y, wjzb.z, 0) } } })
点赞0
评论