用户:没有任何名字查看:1 回复:2 评论:1 创建时间:2022-12-18T13:17:53
有没有js大佬能帮帮忙……

【具体问题】
· 使用一点代码完成如下效果:当玩家从高空摔落时,会根据下列公式受到伤害:
hp -= 0 // 高度小于4格
hp -= 摔落高度 * 0.8 // 高度大于等于4格
· 能否给玩家添加自定义的属性?
entity.player.___
求回复……
名探酱//将可伤害开启
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 > 4) {
entity.hurt(i * 0.8)
entity.player.directMessage('你受到了' + i * 0.8 + '点摔落伤害,目前血量是:' + 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();
});
//别人的代码改了下
点赞1
评论