Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

  • Author
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?

1 minute ago, KidKoderMod033109 said:

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

I think everything except registration events/deferredregisters, and I think the setup events, are on the forge bus.

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.