Skip Death Screen


#1

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


#2

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?


#4

Yes, but player go to spectator mode


#5

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


#6

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


#7

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)


#8

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
}


#9

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


#10

Ok thanks, I try


#11

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.


#12

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