跑酷代码-1
来源:哔哩哔哩     时间:2023-02-19 00:10:09

//冰块打破代码


(资料图片仅供参考)

/* 如果实体碰到冰块,冰块会被打破 */

world.onVoxelContact(({ x, y, z, voxel }) => { const voxelName = voxels.name(voxel); // 将方块id转换名称 

if (voxelName === 'ice'){ // 如果方块名称是冰块 

voxels.setVoxel(x, y, z, 0); // 将方块变成空气 

}

})

//存档点

const saveNpcs = world.querySelectorAll('.存档点')

let saveNpc

for (saveNpc of saveNpcs) {

saveNpc.enableInteract = true; // 允许进行互动

saveNpc.interactRadius = 2;   // 实体的互动范围

saveNpc.onInteract(async ({ entity, targetEntity }) => {

entity.player.spawnPoint.set(targetEntity.position.x, targetEntity.position.y + 2, targetEntity.position.z)

entity.player.directMessage('已刷新存档点,加油')

})

}

//玩家死亡

world.onVoxelContact(async ({ entity, voxel }) => {

if (voxels.name(voxel) === 'grass') {

entity.position.set(entity.player.spawnPoint.x, entity.player.spawnPoint.y, entity.player.spawnPoint.z)

}

})

标签:

广告

X 关闭

广告

X 关闭