Posted August 17, 20214 yr Hi, I made a capability, but my CapabilityEventHandler wont activate the events. I added the code down below. GodsMod.java PlayerInfoEventHandler.java Edited August 17, 20214 yr by Bowtruckle_HD
August 17, 20214 yr Author You mean like this?,when I do that i get the error messageCannot register a generic Event listener with addlistener Edited August 17, 20214 yr by Bowtruckle_HD
August 17, 20214 yr why on earth did you post your classes as an file, post the code here or use github
August 17, 20214 yr Author Sorry about that, did not think any of it. Thats my link, but I'm noot used to Github, so I'm not surei f it works https://github.com/Bowtrucklehd/Modding.git
August 17, 20214 yr Author 4 minutes ago, Luis_ST said: the project doesn't exist or its private I think I changed it
August 17, 20214 yr why on earth in FMLCommonSetupEvent, use this: https://mcforge.readthedocs.io/en/latest/events/intro/#automatically-registering-static-event-handlers
August 17, 20214 yr Author Ok, I registered it now, but it is still not calling the vents. The code is on github if you need it
August 17, 20214 yr package bowtruckle.mods.gods.data; import bowtruckle.mods.gods.tools.Settings; import bowtruckle.mods.gods.tools.Vector3; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import bowtruckle.mods.gods.tools.Settings; @Mod.EventBusSubscriber(modid = Settings.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT) public class PlayerInfoEventHandler { @SubscribeEvent public static void attachCapability(AttachCapabilitiesEvent<Entity> e) { if(e.getObject() instanceof PlayerEntity) { PlayerInfoProvider provider = new PlayerInfoProvider(); e.addCapability(new ResourceLocation(Settings.MODID,"lastPos"), provider); e.addListener(provider::invalidate); } } @SubscribeEvent public static void onPlayerMove(TickEvent.PlayerTickEvent e) { System.out.println("event called"); if(e.getPhase().equals(TickEvent.Phase.END)) { System.out.println("Event Phase End"); e.player.getCapability(CapabilityPlayerInfo.PLAYER_INFO_CAPABILITY).ifPresent(information -> { Vector3 pos = new Vector3(e.player.getPosX(), e.player.getPosY(), e.player.getPosZ()); if (pos == information.getLastPos()) { e.player.setInvisible(true); }else{ e.player.setInvisible(false); } System.out.println(information.getLastPos()); }); } } } Try using this code and remove the register of FMLCommonSetupEvent
August 17, 20214 yr Author Thanks to you I figured it out. i'm gonna mark this as solved now. Btw. Thank you guys very much for helping newbies like me figuring this modding stuff out, it really helps
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.