Open TsuneZebra opened 12 months ago
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)); } } }
Only added a respawn listening event
In the MainClass:
public GokiStats() { instance = this; IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); eventBus.addListener(this::construct); GokiPacketHandler.registerMessages();
//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();