猫史档案馆


求答案,在线等,急!

用户:erha114514erha114514查看:1 回复:2 评论:1 创建时间:2021-06-12T13:55:09


有哪位大佬知道如果碰到水就返回出生点的代码吗?在线等,急!


回复

上一页1 页 / 共 1下一页
VernierVernier

for (const e of world.querySelectorAll('*')) {  //遍历所有实体
    if (e.id.startsWith('存档点')) {  //如果当前实体名左边包含"存档点"
        e.onEntityContact(({ other }) => { //当存档点实体碰到另一个实体
            if (other.isPlayer) { //如果实体是玩家
                if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复做存档
                    other.player.directMessage('已存档') 
                    other.player.spawnPoint = e.position // 设置重生点
                }
            }
        })
    }
}
world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {  //当玩家掉到水里(可以通过侦测玩家脚下的方块改成其他的)
        entity.position.copy(entity.player.spawnPoint)
			entity.position.y += 4  //向上移,做出掉下效果
	})
})

点赞1


评论


VernierVernier

你是梦音工作室的?帮我告诉室长,我出差两个月

点赞0


评论