Skip to content

Commit

Permalink
Fix players dropping their inventories after respawning
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed Jan 6, 2024
1 parent f8e0ddd commit e259123
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e259123

Please sign in to comment.