Posted January 5, 20187 yr I'm done writing the code to add a new item which as far as I'm concerned should be correct, but I'm still getting errors in few class files. The errors as far as I know are for things that are included with forge, so I'm not sure how to fix them. 1. The preInit from the following code is underlined and gives this message: "The method preInit(FMLPreInitializationEvent) is undefined for the type CommonProxy". The same error is in the init and postInit variants as well. There are no errors in the CommonProxy class file either, but I can add it if it's needed. @EventHandler public static void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } 2. The getRegistry() gives the following error "The method getRegistry() is undefined for the type RegistryEvent<Item>". @SubscribeEvent public static void onItemRegister(RegistryEvent<Item> event) { event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0])); } 3. The getRegistryName() gives the following error "The method getReristryName() is undefined for the type ClientProxy". @Override public void registerItemRenderer(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item, getReristryName(), id)); } I'm not sure how common there kinds of errors are, so I'm not sure how much information is needed. Let me know if you need more information on something.
January 5, 20187 yr 46 minutes ago, SusiKette said: 1. The preInit from the following code is underlined and gives this message: "The method preInit(FMLPreInitializationEvent) is undefined for the type CommonProxy". The same error is in the init and postInit variants as well. There are no errors in the CommonProxy class file either, but I can add it if it's needed. You have copied code from someone else. Your CommonProxy class does not contain a preInit(FMLPreInitalizationEvent event) function, yet you are trying to call it. Of course there is no error in the CommonProxy class, this function doesn't exist and there's no reason that your CommonProxy thinks it should. This is the same reasing calling Math.CalculatePie() throws an error. There is also no reason this method should exist either: anything you might do in your common proxy you can do in your main mod class. See Code Style Problem #2. 46 minutes ago, SusiKette said: 3. The getRegistryName() gives the following error "The method getReristryName() is undefined for the type ClientProxy". item.getRegistryName(), you somehow inserted a comma instead of a period, because that function takes 2 parameters. Additionally, you should only be calling this code during the ModelRegistrationEvent. Edited January 5, 20187 yr by Draco18s 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 5, 20187 yr Author 1 hour ago, Draco18s said: You have copied code from someone else. Your CommonProxy class does not contain a preInit(FMLPreInitalizationEvent event) function, yet you are trying to call it. Of course there is no error in the CommonProxy class, this function doesn't exist and there's no reason that your CommonProxy thinks it should. This is the same reasing calling Math.CalculatePie() throws an error. There is also no reason this method should exist either: anything you might do in your common proxy you can do in your main mod class. See Code Style Problem #2. item.getRegistryName(), you somehow inserted a comma instead of a period, because that function takes 2 parameters. Additionally, you should only be calling this code during the ModelRegistrationEvent. I was following a tutorial, so I did things the same way they did. They did edit the video, so I'm not sure if they accidentally edited out the part where they added preInit etc. to CommonProxy. Do I really need those functions in CommonProxy anyways? If not, I'm assuming I can just delete the "proxy.preInit(event);" lines. Also, I'm getting different error after changing the comma to period in item.getRegistryName(). It's on the same place but this time it says "The method getReristryName() is undefined for the type Item"
January 5, 20187 yr 1 hour ago, SusiKette said: The method getReristryName() is undefined for the type Item" You have a typo. 1 hour ago, SusiKette said: Do I really need those functions in CommonProxy anyways? If not, I'm assuming I can just delete the "proxy.preInit(event);" lines. 2 hours ago, Draco18s said: There is also no reason this method should exist either: anything you might do in your common proxy you can do in your main mod class. See Code Style Problem #2. 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 5, 20187 yr Author Thanks for the help so far Assuming I understood what was in the link (I'm not a native English speaker, so I might derp sometimes :p), the lines I mentioned are not needed. The only error that still remains it the second one in the original post. And as a last kinda unrelated note, I kinda wish Eclipse had some sort of spell check to avoid these kinds of errors from happening ^^;; Edited January 5, 20187 yr by SusiKette
January 5, 20187 yr It needs to be RegistryEvent.Register not just the base class more info https://mcforge.readthedocs.io/en/latest/concepts/registries/ Did you really need to know?
January 6, 20187 yr Author EDIT: Got it working now. There were some problems in the json files and the folder names, but I was able to fix them in the end Thanks for the help! Edited January 6, 20187 yr by SusiKette
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.