Skip Death Screen

I want to skip death screen without respawn

@Listener
public void onPlayerTakeDamage(DamageEntityEvent event,@First Player player){
if(event.willCauseDeath()) {
     event.setCancelled(true);
}

But mod that I use detect death event
I tried

@Listener
public void onPlayerKilled(DestructEntityEvent.Death event, @First Player player){
     player.respawnPlayer();
}

But, it’s work after death screen
I want that
If player die he go to spectate mode without death screen and I have mod which detect only
death

So essentially you want the ability to not die? As in when the player should die they drop all items, set to full health and food?

Yes, but player go to spectator mode

Ah. That makes more sense. Thanks for the edit. Im confused on why cancelling the damage event will still cause the death screen. Even says in the description for the function that canceling the event will cause the function to return false.

Returns whether or not this event will cause the entity to die if the event is not cancelled.

Are you sure the event is even firing? If not check that the listener is registered

It’s works player go to spectator mode,
the problem is different, player should die they drop all items, how death event, without death screen

Then get the player to drop all items?

Player player;
player.getInventory().slots().stream().filter(s -> s.peek().isPresent()).forEach(s -> {
    Item item = player.getLocation().createEntity(EntityTypes.ITEM);
    item.offer(keys.REPRESENTED_ITEM, s.peek().get());
    player.getWorld().spawnEntity(item);
});

Im on my phone, been sitting on a train in hot temperatures (for Britain) for the past 2:30 hours so sorry if its not exactly correct)

It’s possible call DeathEvent without death screen?
@Listener
public void onPlayerTakeDamage(DamageEntityEvent event,@First Player player){
if(event.willCauseDeath()) {
event.setCancelled(true);
Call DeathEvent
}

I dont believe so. I believe its thrown when the death screen is activated

Edit:
Just seen your edit, you can manually call the death event like that, can not remember how to call sponge events though

1 Like

Ok thanks, I try

I don’t know if that still works, but you might be able to revive the player by setting their health 1 tick after the death event. That would leave all items dropped, as no event is cancelled and iirc it removes the death screen.

DosMike
Yes, It’s works, thanks, but one problem I see death screen