Jump to content

(Solved)[1.15.2]Why cannot my cord detect events?


Recommended Posts

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;

public class TestMod {
  public static final String MODID = "testmod";
  public static final Logger LOGGER = LogManager.getLogger(MODID);

  public TestMod() {
    LOGGER.debug("Mod Loaded.");

  public void testFunc(TickEvent.PlayerTickEvent event) {

  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 by kyazuki
Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.