fix: correctly refresh client state on death

This commit is contained in:
mworzala 2024-02-10 17:41:57 -05:00
parent 9ed8605edc
commit 77df1bdfd2
No known key found for this signature in database
GPG Key ID: B148F922E64797C7
3 changed files with 18 additions and 1 deletions

View File

@ -73,6 +73,7 @@ public class Main {
commandManager.register(new SidebarCommand());
commandManager.register(new SetEntityType());
commandManager.register(new RelightCommand());
commandManager.register(new KillCommand());
commandManager.setUnknownCommandCallback((sender, command) -> sender.sendMessage(Component.text("Unknown command", NamedTextColor.RED)));

View File

@ -0,0 +1,16 @@
package net.minestom.demo.commands;
import net.minestom.server.command.builder.Command;
import net.minestom.server.entity.Player;
public class KillCommand extends Command {
public KillCommand() {
super("kill");
setDefaultExecutor((sender, context) -> {
if (sender instanceof Player player) {
player.kill();
}
});
}
}

View File

@ -519,10 +519,10 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
sendPacket(new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
0, gameMode, gameMode, false, levelFlat, deathLocation, portalCooldown, RespawnPacket.COPY_ALL));
refreshClientStateAfterRespawn();
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
EventDispatcher.call(respawnEvent);
triggerStatus((byte) (24 + permissionLevel)); // Set permission level
refreshIsDead(false);
updatePose();