#Can KubeJS make a specific player die without a death screen? (Almost like Immediate Respawn)
12 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Can KubeJS make a specific player die without a death screen? (Almost like Immediate Respawn)
EntityEvents.hurt(event=>{
if(!event.entity.player) return;
if(event.damage < event.player.health) return;
let {x, y, z} = event.level.sharedSpawnPos
if(event.player.nbt.SpawnX) [x, y, z] = [event.player.nbt.SpawnX, event.player.nbt.SpawnY, event.player.nbt.SpawnZ]
event.player.teleportTo(x, y, z)
event.player.heal(event.player.maxHealth)
event.player.extinguish()
event.player.setFoodLevel(20)
event.player.setAirSupply(event.player.maxAirSupply)
event.cancel()
})
It seems impossible to cancel a death event or force players to esc the death menu. A work around would be to test if they're getting fatal damage, cancel that damage and teleport them back to spawn point.
isn't there a respawn() method on Player?
just listen to the death event and call that ig
Yes. I tried that first but it did not work as expect
So, this checks before they die?
Like before their health hits 0?
yes
Thanks! I'll try it out in a bit to see if it works
It works, thank you so much!