OverlordsIII / ConfiguredKeepInventory

A serverside fabric mod that allows you to control how many items drop when you die
https://www.curseforge.com/minecraft/mc-mods/configured-keep-inventory
6 stars 0 forks source link

Exp reset when exiting end portal #6

Closed kokobunx closed 1 year ago

kokobunx commented 3 years ago

Exp is reset upon exiting the end through end portal

FractalThought commented 2 years ago

This issue can be fixed by adding !alive && to the beginning of the if-statement on line 54 in ServerPlayerEntityMixin.java. As it is, exiting the end dimension through the Exit Portal runs the same code as if a player died and then checks if XP should be lost on death or not.

Adding a check for if the player is alive or not means the XP-reset won't happen when exiting the End through the Exit Portal (this mirrors how the original game code does it).

@Inject(method = "copyFrom", at = @At("TAIL"))
    private void changeXP(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo ci) {
        if (!alive && ConfiguredKeepInventory.Config.enableConfig && ConfiguredKeepInventory.Config.loseXpOnDeath
                && !this.world.getGameRules().getBoolean(GameRules.KEEP_INVENTORY)) {
            this.experienceLevel = 0;
            this.experienceProgress = 0;
            this.totalExperience = 0;
        }
    }