Posted January 31, 20205 yr I have a research table and you need to research a couple of recipes before you can craft them. I want to use the PlayerEvent.ItemCraftedEvent to check if a player has learned it. How would I do something like this?
January 31, 20205 yr Author 58 minutes ago, diesieben07 said: You can use capabilities to attach data to existing entities. Thanks, I didn't know you could use capabilities on enities!
January 31, 20205 yr Author 1 hour ago, diesieben07 said: You can use capabilities to attach data to existing entities. How do I attach my capability to the player?https://github.com/DJ1TJOO/fantasy20
January 31, 20205 yr Author Just now, Cyborgmas said: It's an event, something like OnAttachCapability<Entity> Yeeh but it asks for a capability provider and a resource location both I do not have
January 31, 20205 yr Author 1 minute ago, diesieben07 said: You don't attach a capability, you attach an ICapabilityProvider, which then exposes your capability. It's an interface, you need to implement it. The ResourceLocation is to uniquely identify your attached provider. Do I need to implement it in a new class or in my class wich extends my capability interface?
January 31, 20205 yr Author 2 minutes ago, diesieben07 said: It's an interface. Nobody cares how or where you implement it. That is the point of an interface. Do I need to register it somewhere?
January 31, 20205 yr Author 17 minutes ago, diesieben07 said: No, you attach it using the event. playerIn.getCapability(CapabilityResearchProvider.RESEARCH_CAPABILITY, null).ifPresent(r -> {System.err.println("c");}); never works. https://github.com/DJ1TJOO/fantasy20/blob/master/src/main/java/nl/fantasynetworkmc/fantasy20/items/Blueprint.java#L41
January 31, 20205 yr Author 1 hour ago, DJ1TJOO said: playerIn.getCapability(CapabilityResearchProvider.RESEARCH_CAPABILITY, null).ifPresent(r -> {System.err.println("c");}); never works. https://github.com/DJ1TJOO/fantasy20/blob/master/src/main/java/nl/fantasynetworkmc/fantasy20/items/Blueprint.java#L41 I think I've found the problem but do not know how to solve it. The AttachCapabilitiesEvent<Entity> is not firing:https://github.com/DJ1TJOO/fantasy20/blob/master/src/main/java/nl/fantasynetworkmc/fantasy20/setup/RegistryEvents.java#L121
January 31, 20205 yr https://github.com/DJ1TJOO/fantasy20/blob/master/src/main/java/nl/fantasynetworkmc/fantasy20/setup/RegistryEvents.java#L44 That's the wrong bus. Don't combine your event handlers like this. AttachCap is not a registry event, its a game event. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 31, 20205 yr Author 5 minutes ago, Draco18s said: https://github.com/DJ1TJOO/fantasy20/blob/master/src/main/java/nl/fantasynetworkmc/fantasy20/setup/RegistryEvents.java#L44 That's the wrong bus. Don't combine your event handlers like this. AttachCap is not a registry event, its a game event. What bus does it need to be I made a new class GameEvents and registered it in the Fantasy20 class with MinecraftForge.EVENT_BUS.register(GameEvents.class); Its has the @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)https://github.com/DJ1TJOO/fantasy20/tree/master/src/main/java/nl/fantasynetworkmc/fantasy20 O and also my GuiOpenEvent is not firing on the main screen Edited January 31, 20205 yr by DJ1TJOO
January 31, 20205 yr 9 minutes ago, DJ1TJOO said: What bus does it need to be There's only two and that one's the wrong one. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
January 31, 20205 yr Author 2 minutes ago, Draco18s said: There's only two and that one's the wrong one. OO you meen Mod.EventBusSubscriber.Bus.FORGE. I thaught it was something totaly different Edit: Or not? Because it doesn't work Edited January 31, 20205 yr by DJ1TJOO
February 1, 20205 yr show your updated code Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
February 1, 20205 yr Author 11 hours ago, Draco18s said: show your updated code Its on the github: https://github.com/DJ1TJOO/fantasy20/tree/master/src/main/java/nl/fantasynetworkmc/fantasy20 but I think Someone else found the solution I need to make the functions static but I have no time to try it out It works Thanks! Edited February 1, 20205 yr by DJ1TJOO
February 1, 20205 yr You event subscribe methods here, here and here are not static but you register you class here with the annotation and here with the register class method. You might want to read the documentation on events again. You also register your RegistryEvents to the FORGE event bus here but also register it to the MOD event bus with the annotation here. You should only register your class once AND the RegistryEvents class only handles events that fire on the MOD event bus so registering it to the FORGE event bus is pointless. Other stuff I’ve noticed: - You don’t need a proxy but still use one - Registry#registerAll exists and can be used to register many objects at the same time more cleanly - Your mod would be better suited using DeferredRegister About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
February 1, 20205 yr Author 12 minutes ago, Cadiboo said: Your mod would be better suited using DeferredRegister What do you mean? I did the registerAll Edited February 1, 20205 yr by DJ1TJOO
February 1, 20205 yr Just now, DJ1TJOO said: What do you mean? You don’t do any complex or iterative registration so using DeferredRegister would simplify and clean up your code a ton About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
February 1, 20205 yr Author 3 minutes ago, Cadiboo said: You don’t do any complex or iterative registration so using DeferredRegister would simplify and clean up your code a ton Does it make my mod faster or does it any thing else better? Because I never know what I need to add and maby later I need a 5 minutes ago, Cadiboo said: complex or iterative registration
February 1, 20205 yr 1 minute ago, DJ1TJOO said: Does it make my mod faster or does it any thing else better? It makes your code simpler. You can still do iterative registration with DeferredRegister and unless you’re doing something very complicated (which you probably shouldn’t be) you can do complex registration too. About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
February 1, 20205 yr Author 2 minutes ago, Cadiboo said: It makes your code simpler. You can still do iterative registration with DeferredRegister and unless you’re doing something very complicated (which you probably shouldn’t be) you can do complex registration too. Then I'm gonna change it. Is there a good way todo it or just as the example is fine?
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.