Posted January 23, 20205 yr I'm a new to modding minecraft. I tried to set the max health when a player login, but nothing happened. Not only that, testFunc didn't run. Please help... package com.github.kyazuki.testmod; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod(TestMod.MODID) @Mod.EventBusSubscriber public class TestMod { public static final String MODID = "testmod"; public static final Logger LOGGER = LogManager.getLogger(MODID); public TestMod() { LOGGER.debug("Mod Loaded."); } @SubscribeEvent public void testFunc(TickEvent.PlayerTickEvent event) { LOGGER.debug("tick!"); } @SubscribeEvent public void setPlayerHealth(PlayerEvent.PlayerLoggedInEvent event) { PlayerEntity player = (PlayerEntity) event.getEntity(); player.getAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("MaxHealth", 10.0f, AttributeModifier.Operation.ADDITION)); } } Edited January 23, 20205 yr by kyazuki
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.