From e259123f58f3f65cdf556b59eb9362b877f7599a Mon Sep 17 00:00:00 2001 From: haykam821 <24855774+haykam821@users.noreply.github.com> Date: Sat, 6 Jan 2024 17:58:55 -0500 Subject: [PATCH] Fix players dropping their inventories after respawning --- .../game/phase/BeaconBreakersActivePhase.java | 18 ++++++++---------- .../game/player/PlayerEntry.java | 8 ++++++++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/io/github/haykam821/beaconbreakers/game/phase/BeaconBreakersActivePhase.java b/src/main/java/io/github/haykam821/beaconbreakers/game/phase/BeaconBreakersActivePhase.java index 14dd11f..f8adb24 100644 --- a/src/main/java/io/github/haykam821/beaconbreakers/game/phase/BeaconBreakersActivePhase.java +++ b/src/main/java/io/github/haykam821/beaconbreakers/game/phase/BeaconBreakersActivePhase.java @@ -305,31 +305,29 @@ private ActionResult onPlayerDeath(ServerPlayerEntity player, DamageSource sourc } PlayerEntry entry = this.getEntryFromPlayer(player); - boolean eliminated = false; if (entry != null) { if (this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES)) { this.gameSpace.getPlayers().sendMessage(player.getDamageTracker().getDeathMessage()); } + if (!this.config.shouldKeepInventory()) { + entry.dropInventory(); + } + if (this.attemptBeaconRespawn(entry) == ActionResult.FAIL) { if (this.invulnerability > 0) { BeaconBreakersActivePhase.spawn(this.world, this.map, this.config.getMapConfig(), entry.getPlayer()); } else { + if (this.config.shouldKeepInventory()) { + entry.dropInventory(); + } + this.eliminate(entry); - eliminated = true; } } } - if (eliminated || !this.config.shouldKeepInventory()) { - player.vanishCursedItems(); - player.getInventory().dropAll(); - - player.dropXp(); - player.dropShoulderEntities(); - } - player.setHealth(player.getMaxHealth()); player.getHungerManager().setFoodLevel(20); diff --git a/src/main/java/io/github/haykam821/beaconbreakers/game/player/PlayerEntry.java b/src/main/java/io/github/haykam821/beaconbreakers/game/player/PlayerEntry.java index 83b7459..ed94f4c 100644 --- a/src/main/java/io/github/haykam821/beaconbreakers/game/player/PlayerEntry.java +++ b/src/main/java/io/github/haykam821/beaconbreakers/game/player/PlayerEntry.java @@ -83,6 +83,14 @@ public void initializePlayer() { this.player.addStatusEffect(new StatusEffectInstance(StatusEffects.SATURATION, this.phase.getInvulnerability(), 127, true, false)); } + public void dropInventory() { + this.player.vanishCursedItems(); + this.player.getInventory().dropAll(); + + this.player.dropXp(); + this.player.dropShoulderEntities(); + } + public void sendMessage(Text message, boolean overlay) { if (this.player != null) { this.player.sendMessage(message, overlay);