Posted April 15, 20205 yr 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 Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 15, 20205 yr You're registering the class on the mod event bus, but those are forge event bus events.
April 15, 20205 yr 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.
April 15, 20205 yr 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? Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 15, 20205 yr 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.
April 15, 20205 yr Author Ok great! Website: http://kidkoder.net GitHub: https://github.com/Uncodeable864
April 15, 20205 yr 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.