用户:
Star_Ink_sans查看:29 回复:17 评论:29 创建时间:2022-03-15T11:14:49
代码如下:
//将可伤害开启
world.onPlayerJoin(({ entity }) => {
entity.enableDamage = true;
});
//摔落伤害
world.onVoxelContact(async ({ entity, x, y, z, voxel }) => {
if (!entity.isPlayer) return;
let i = entity.player.fall - y
if (entity.player.fall - y > 10) {
entity.hurt(i * 3)
entity.player.directMessage('你受到了' + i * 3 + '点摔落伤害,目前血量是:' + entity.hp)
}
entity.player.fall = y
});
//处理特殊情况:水方块
world.onFluidEnter(async({entity,voxel})=>{
if(!entity.isPlayer){return;}
entity.player.fall=0
})
//这里的复活代码@吉吉喵
world.onDie(async({ entity }) => {
if (!entity.isPlayer) return;
for (let t = 1; t <= 5; t++) {
entity.player.directMessage(`倒计时 ${String(5 - t)} 秒后复活`);
await sleep(1000);
}
entity.player.forceRespawn();
});