OverlordsIII / ConfiguredKeepInventory

A serverside fabric mod that allows you to control how many items drop when you die

Home Page:https://www.curseforge.com/minecraft/mc-mods/configured-keep-inventory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exp reset when exiting end portal

kokobunx opened this issue · comments

Exp is reset upon exiting the end through end portal

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;
        }
    }