Jump to content

[1.15] Events not registering/exucuting


KidKoderMod033109

Recommended Posts

Hi,

I was working on my mod's events and found the the evnevs where not running in-game. I do not know what is going on. Hre is my code:

 
 
0
 Advanced issue found
 
 
Spoiler

/*
 * Koded by Kid Koder :)
 *
 *  % : ° ° : %
 *       O
 */

package net.kidkoder.allergies.system;

import net.kidkoder.allergies.capability.allergies.AllergiesProvider;
import net.kidkoder.allergies.capability.allergies.IAllergies;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;


@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
public class Events {

    SystemAssignment assignment = new SystemAssignment();

    @SubscribeEvent
    public void newPlayerJoinWorld(PlayerEvent.PlayerLoggedInEvent event) {
        PlayerEntity player = event.getPlayer();

        StringTextComponent textWorked = new StringTextComponent("In the event");
        player.sendMessage(textWorked);

        IAllergies allergies = (IAllergies) player.getCapability(AllergiesProvider.ALLERGIES_CAP);

        if(allergies.rolled()) {
            StringTextComponent textLoad = new StringTextComponent("Loaded allergies");
            player.sendMessage(textLoad);
        } if(!allergies.rolled()) {
            assignment.roll(player, player.getEntityWorld());
            StringTextComponent textRoll = new StringTextComponent("Allergies rolled");
            player.sendMessage(textRoll);
        }

    }

    @SubscribeEvent
    public void playerClone(PlayerEvent.Clone event) {
        /*
       Transfer Capability
         */
        PlayerEntity newPlayer = event.getPlayer();
        IAllergies allergies = (IAllergies) newPlayer.getCapability(AllergiesProvider.ALLERGIES_CAP);
        IAllergies oldAllergies = (IAllergies) event.getOriginal().getCapability(AllergiesProvider.ALLERGIES_CAP, null);

        allergies.setAllergens(oldAllergies.getAllergens());

    }

}

 

Thanks in advance,

Kid Koder

Link to comment
Share on other sites

2 minutes ago, Ugdhar said:

You're registering the class on the mod event bus, but those are forge event bus events.

@KidKoderMod033109 Also you register the class with @EventBusSubscriber but your methods are not static.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

10 minutes ago, Ugdhar said:

You're registering the class on the mod event bus, but those are forge event bus events.

 

6 minutes ago, Animefan8888 said:

@KidKoderMod033109 Also you register the class with @EventBusSubscriber but your methods are not static.

Great worked! But how to I check what event bus a event needs?

Link to comment
Share on other sites

Hi

Based on my testing so far:

    // Based on my testing: ModEventBus is used for setup events only, in the following order:
    // * RegistryEvent of all types
    // * ColorHandlerEvent for blocks & items
    // * ParticleFactoryRegisterEvent
    // * FMLCommonSetupEvent
    // * TextureStitchEvent
    // * ModelBakeEvent 
    // * FMLClientSetupEvent or FMLDedicatedServerSetupEvent
    // * ModelRegistryEvent
    // * Other ModLifecycleEvents such as InterModEnqueueEvent, InterModProcessEvent
    // Everything else: the MinecraftForge.EVENT_BUS

 

Easy enough to tell using a breakpoint if you've chosen the wrong one.

 

-TGG

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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