Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max Health death reset issue fixed #102

Open
TsuneZebra opened this issue Nov 24, 2023 · 0 comments
Open

Max Health death reset issue fixed #102

TsuneZebra opened this issue Nov 24, 2023 · 0 comments

Comments

@TsuneZebra
Copy link

Only added a respawn listening event

In the MainClass:

public GokiStats() {
instance = this;
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener(this::construct);
GokiPacketHandler.registerMessages();

    MinecraftForge.EVENT_BUS.addListener(this::onPlayerRespawn); //Add this
}

//add this
private void onPlayerRespawn(PlayerEvent.Clone event) {
if (event.isWasDeath() && event.getOriginal() instanceof ServerPlayerEntity) {
ServerPlayerEntity originalPlayer = (ServerPlayerEntity) event.getOriginal();
ServerPlayerEntity newPlayer = (ServerPlayerEntity) event.getPlayer();

        StatBase stat = StatBase.stats.get(21);
        final int level = DataHelper.getPlayerStatLevel(originalPlayer, stat);
        if (stat.isEnabled()) {
            newPlayer.getAttribute(Attributes.MAX_HEALTH)
                    .setBaseValue(20 + stat.getBonus(level));
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants