Jump to content

1.12.2 Registry Issues


aliteraryhigh

Recommended Posts

Here is my GitHub repo with the current stuff I have to go from. I'm having issues with the EventRegistry and cannot for the life of me get this mod to initialize properly. It either crashes on startup, or with minor changes (commenting out the registry lines in ModBlocks.java and ModItems.java) doesn't even load the items. I've tried every tutorial and have searched for the last 5 hours for answers and can't figure out what's wrong. Below are the relevant crash log lines, emphasis mine. I know that I'm not registering the blocks/items correctly but can't figure out how to get them registered properly. Anyone have any help?

 

Quote

---- Minecraft Crash Report ----
// You're mean.

Time: 10/28/19 10:34 PM
Description: Initializing game

java.lang.NullPointerException: Can't use a null-name for the registry, object null.
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:294)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:288)
    at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:120)
    at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:161)
    at FruitBushes.init.ModBlocks.registerBlocks(ModBlocks.java:48)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_11_ModBlocks_registerBlocks_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:847)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.init(Minecraft.java:514)
    at net.minecraft.client.Minecraft.run(Minecraft.java:422)
    at net.minecraft.client.main.Main.main(Main.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    at GradleStart.main(GradleStart.java:25)

 

Link to comment
Share on other sites

So now that I was finally able to finish registering this account (lost my old one), here's an update on my github repo.

 

The mod loads, finally. I can test run it in Eclipse and it does not crash. However, I'm still having issues. The textures don't load for the items, the names don't properly load, the name of the tab in Creative Mode doesn't display properly, none of the items show up in the new Creative Mode tab, and I can't actually plant the seeds on any type of soil. I'm at my wits' end and have pared down the code on almost every class so far and still nothing. But the mod loads and the recipes work, which I guess is good. Anyone have any suggestions?

Link to comment
Share on other sites

6 hours ago, aliteraryhigh said:

The textures don't load for the items, the names don't properly load, the name of the tab in Creative Mode doesn't display properly

Your resource file structure is incorrect. you have assets/FruitBushes/... you cannot have any capitals in your resources.

 

6 hours ago, aliteraryhigh said:

none of the items show up in the new Creative Mode tab

Why does this method even exist? When you initialize them in the event like you are supposed to. This likely messes things up somewhere.

 

Oh fuck...what...what is this?

 

Let's talk a bit here...First you create your seeds and store the values in the static fields at the top of the class. Good good. Then you proceed to register completely different instances and expect them to work. You didn't even use the same classes for these items. Also this totals up to 3 initializations of those items. Once in the init method called from preInit(not the proper way to do it), secondly in the registry event, and thirdly right below the second time...

6 hours ago, aliteraryhigh said:

Anyone have any suggestions?

I have one really important suggestion. And it will help you a long way into programming. Don't start learning with making a mod. You should learn the basics of programming(kinda looks like you have to an extent). Then you should learn the language you will be writing in; in this case Java. You can do both of those at the same time. The reason I say this is that learning to program by immediately jumping in to using an API, especially Forge is not something anyone can do and is incredibly hard. I don't want you to be discouraged by this. If you want to make a mod, or if you want to learn how to program and make your own game(s) you should start small. Watch/read some tutorials on programming. Experiment by making small programs like pong, a calculator, tic-tac-toe, etc.

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.

Link to comment
Share on other sites

5 hours ago, Animefan8888 said:

Your resource file structure is incorrect. you have assets/FruitBushes/... you cannot have any capitals in your resources.

Didn't know that, I'll change that tonight after work!

 

 

5 hours ago, Animefan8888 said:

 

Why does this method even exist? When you initialize them in the event like you are supposed to. This likely messes things up somewhere.

 

Not sure, that should have been taken out. I've been doing most of this work later at night after work so I know I've missed quite a lot. That and at this point I've rebuilt all the code from scratch twice.

 

 

5 hours ago, Animefan8888 said:

Oh fuck...what...what is this?

 

So far? That's the only way I've gotten the items to actually register. Any other way I've done the registry events, the items haven't actually registered. Several times I've had the mod crash the entire client instead of even loading. Please let me know if there's a smarter way to do that, because I've spent a collective 8-10 hours searching these forums, reddit, the official minecraft forums, stackexchange, and github trying to find ANY tutorial that has even the slightest chance of working.

5 hours ago, Animefan8888 said:

 

Let's talk a bit here...First you create your seeds and store the values in the static fields at the top of the class. Good good. Then you proceed to register completely different instances and expect them to work. You didn't even use the same classes for these items. Also this totals up to 3 initializations of those items. Once in the init method called from preInit(not the proper way to do it), secondly in the registry event, and thirdly right below the second time...

 

I'm initializing it twice in the same class? Now that you point that out, I think I see what you're talking about. You mean this section here? I see where I define them twice, that's something I'll correct tonight as well.

 

5 hours ago, Animefan8888 said:

I have one really important suggestion. And it will help you a long way into programming. Don't start learning with making a mod. You should learn the basics of programming(kinda looks like you have to an extent). Then you should learn the language you will be writing in; in this case Java. You can do both of those at the same time. The reason I say this is that learning to program by immediately jumping in to using an API, especially Forge is not something anyone can do and is incredibly hard. I don't want you to be discouraged by this. If you want to make a mod, or if you want to learn how to program and make your own game(s) you should start small. Watch/read some tutorials on programming. Experiment by making small programs like pong, a calculator, tic-tac-toe, etc.

 

I've been coding for a little over a decade now, but I haven't touched Java at all in the last 5 years. The last time I touched Java was making a simple mod for vanilla Minecraft. As I'm sure you're aware, Minecraft (and more specifically Forge) hasn't exactly gotten easier to work with. I was working on this just for personal use and because I'm tired of using VBS all day at work lol. I'm not discouraged by a video game's code being annoying to work with, though I must admit I got fairly frustrated at the lack of depth of the official forge documentation.

 

Would you say the issues you listed in your comment are the main contributing factors to the seeds not planting properly/the models not loading correctly?

Link to comment
Share on other sites

3 hours ago, aliteraryhigh said:

Would you say the issues you listed in your comment are the main contributing factors to the seeds not planting properly/the models not loading correctly?

Yes, what you have there is the problem. Its against basic object oriented programming. The values you pass in to the register function aren't an instance of your Seed classes they aren't even the same instance. The code should look something like

 

registerItems(event)

    event.getRegistry().register(BLACKBERRY_SEED = new FruitSeed(...));

...

Edited by Animefan8888

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.

Link to comment
Share on other sites

...or don't even set the field yourself and use object holders

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.

Link to comment
Share on other sites

2 hours ago, Animefan8888 said:

Yes, what you have there is the problem. Its against basic object oriented programming. The values you pass in to the register function aren't an instance of your Seed classes they aren't even the same instance. The code should look something like

 

registerItems(event)

    event.getRegistry().register(BLACKBERRY_SEED = new FruitSeed(...));

...

 

So I'll try:

 

event.getRegistry().register(BLACKBERRY_SEED = new FruitSeed(ModBlocks.BlockBlackberry, Blocks.FARMLAND));

 

and that should work, correct?

 

 

48 minutes ago, Draco18s said:

...or don't even set the field yourself and use object holders

 

That was one of the attempts I tried and I don't seem to have a full grasp on how forge uses object holders. I spent a solid 2 hours reading the forge documentation over the weekend and came out further confused than I already was. It's not exactly written in an understandable fashion for most people, which is one of the main complaints I've seen in other similar threads to mine.

Link to comment
Share on other sites

13 minutes ago, aliteraryhigh said:

and that should work, correct?

You'll also need to give it a registry name, but as long as you've made the FruitSeed class it should work.

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.

Link to comment
Share on other sites

3 hours ago, Animefan8888 said:

You'll also need to give it a registry name, but as long as you've made the FruitSeed class it should work.

 

What exactly would be in the FruitSeed class? Just an extension of ItemSeeds, correct? That keeps throwing constructor errors in Eclipse. The code below is what I have so far for the class and I'm not quite sure what I'm missing. The "crops" and "soil" values can be set in the individual seed classes with an override, so I'm not too worried about that. But the "public FruitSeed" line keeps throwing the error "Implicit super constructor ItemSeeds() is undefined. Must explicitly invoke another constructor" and I'm not quite sure why, as it's a defined constructor in the ItemSeeds class that the FruitSeed class extends.

 

Spoiler

package FruitBushes.Items;

import FruitBushes.init.ModBlocks;
import net.minecraft.block.Block;
import net.minecraft.item.ItemSeeds;

public class FruitSeed extends ItemSeeds implements net.minecraftforge.common.IPlantable {

    private final Block crops;
    /** BlockID of the block the seeds can be planted on. */
    private final Block soilBlockID;
    
    public FruitSeed(Block crops, Block soil)
    {
        this.crops = crops;
        this.soilBlockID = soil;
    }
}

 

Link to comment
Share on other sites

You know, there's already a class that seeds use and you don't need to extend it.

BlockNamedItem

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.

Link to comment
Share on other sites

1 hour ago, Draco18s said:

You know, there's already a class that seeds use and you don't need to extend it.

BlockNamedItem

 

I'm not sure where you're seeing that. I've searched the entire source jar and haven't found any reference to that anywhere, are you talking about 1.12.2? The main class I've seen that seeds use is ItemSeeds.

Link to comment
Share on other sites

UPDATE:

 

I was able to get it mostly working.

 

The seeds register properly, and I still need to clean up the class files for the Blueberry, Maloberry, and Raspberry seeds to match the BlackberrySeeds formatting. Same goes for the block classes. As it stands, the example textures for the seeds work also. The seeds will plant, the crops will grow the appropriate amount of stages, and the crops will drop seeds and fruit. However, the textures for the crops still do not load. Additionally, the item names are not correctly displaying, the creative tab name is not correctly displaying, and the items do not show up in the creative tab. I do still have a fair bit of work to do but I feel as though I've got a much better handle on modding 1.12.2 as far as this is concerned. My next project is going to be in 1.14, so that will be interesting. Thanks all for the help!

Link to comment
Share on other sites

Oh sorry, 1.12

You're looking for ItemSeeds

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.

Link to comment
Share on other sites

1 minute ago, aliteraryhigh said:

However, the textures for the crops still do not load. Additionally, the item names are not correctly displaying, the creative tab name is not correctly displaying, and the items do not show up in the creative tab. I do still have a fair bit of work to do but I feel as though I've got a much better handle on modding 1.12.2 as far as this is concerned. My next project is going to be in 1.14, so that will be interesting. Thanks all for the help!

Your lang file is still in an Upper Case folder:

https://github.com/aliteraryhigh/FruitBushes/tree/11-04-19/src/main/resources/assets/FruitBushes

As are your block models and block textures

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.

Link to comment
Share on other sites

36 minutes ago, Draco18s said:

Your lang file is still in an Upper Case folder:

https://github.com/aliteraryhigh/FruitBushes/tree/11-04-19/src/main/resources/assets/FruitBushes

As are your block models and block textures

 

Huh, that's weird. On GitHub desktop it shows up properly cased, as well as in Eclipse. Same story for the actual files on my hard drive, too. I went through and renamed the subpackages and then rerenamed it back to "fruitbushes" and it's still not working properly.

Link to comment
Share on other sites

Rename it to something else, completely unrelated, push that to github, then rename it back and push that.

 

1) Windows doesn't give a fuck about case, so its lying to you

2) Git does care about case and for some reason it saw the change on only some of the files.

 

Rename, push, rename will fix it

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.

Link to comment
Share on other sites

Interestingly enough, even with the case change it's not working properly. I feel like I may have called the wrong block name somewhere in here, but it's getting a bit late for me to spend a lot of time taking a look at it. I will have to check on this tomorrow night and do some further testing. If you find a problem in the meantime let me know!

 

Thanks

Link to comment
Share on other sites

https://github.com/aliteraryhigh/FruitBushes/blob/11-04-19/src/main/java/FruitBushes/init/ModBlocks.java#L38-L43

You should still use object holders IMO.

https://github.com/aliteraryhigh/FruitBushes/blob/11-04-19/src/main/java/FruitBushes/Blocks/BlockBlackberry.java#L26

You take in a string name and then do fuckall with it.

And by calling setRegistryName here, its possible that your block is getting the wrong domain. Forge will apply a domain automatically, but if you're using setRegistryName at the wrong time, it will apply the wrong mod ID.

https://github.com/aliteraryhigh/FruitBushes/blob/11-04-19/src/main/java/FruitBushes/Items/BlackberrySeeds.java#L17

Ditto your items, though you construct them in the Register<Item> event, so setRegistryName here works fine.

Also, your unlocalized name should contain your mod ID to prevent conflicts.

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.

Link to comment
Share on other sites

On 11/5/2019 at 10:31 AM, Draco18s said:

https://github.com/aliteraryhigh/FruitBushes/blob/11-04-19/src/main/java/FruitBushes/init/ModBlocks.java#L38-L43

You should still use object holders IMO.

https://github.com/aliteraryhigh/FruitBushes/blob/11-04-19/src/main/java/FruitBushes/Blocks/BlockBlackberry.java#L26

You take in a string name and then do fuckall with it.

And by calling setRegistryName here, its possible that your block is getting the wrong domain. Forge will apply a domain automatically, but if you're using setRegistryName at the wrong time, it will apply the wrong mod ID.

https://github.com/aliteraryhigh/FruitBushes/blob/11-04-19/src/main/java/FruitBushes/Items/BlackberrySeeds.java#L17

Ditto your items, though you construct them in the Register<Item> event, so setRegistryName here works fine.

Also, your unlocalized name should contain your mod ID to prevent conflicts.

 

With the changes shown here, I'm getting the error listed below. I'm not sure why it's giving me variant errors on maloberry stage 4, as there is no stage 4 for maloberry and I triple checked to make sure it still shows 3 ages.

 

Update during comment: I quadruple checked and I might be a massive moron. Forgot the @Override tag on setting the max age in the block classes. It still doesn't work, but that's one thing I need to change on all of them.

 

 

error log.txt

Link to comment
Share on other sites

14 hours ago, diesieben07 said:

Your JSON is invalid.

 

Between the official forge documentation and this comment, I've almost got enough information to start looking for the problem.

 

In all seriousness, I'm not quite getting how it's invalid. I've looked at tutorials, other mods, vanilla blocks/items, and directly mimicked the structure of all of them and it's still not working.

 

Link to comment
Share on other sites

5 hours ago, aliteraryhigh said:

I'm not quite getting how it's invalid.

19 hours ago, diesieben07 said:

at line 7 column 6 path $.variants.

There's an extra comma in the line above (meaning in line 6) which makes the compiler expect another entry to be on line 7, where there isn't one. You should get a JSON checking plugin for Eclipse, or use an online one, since these sorts of things crop up every now and then and are generally tedious to find.

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

Link to comment
Share on other sites

11 hours ago, SerpentDagger said:

There's an extra comma in the line above (meaning in line 6) which makes the compiler expect another entry to be on line 7, where there isn't one. You should get a JSON checking plugin for Eclipse, or use an online one, since these sorts of things crop up every now and then and are generally tedious to find.

 

I'll make sure to get a decent plugin tonight for it. The comma issue isn't in the blockstate json for the blackberry crop, but it still doesn't show the model for that one either. Is my formatting correct in the json file, or is there something else I'm missing? Like i said, this is a direct copy of a working blockstate json with nothing but the modid and reference changed.

Link to comment
Share on other sites

10 hours ago, diesieben07 said:

Post updated logs.

 

I'm here with an updated repo and updated logs. I was missing some close brackets in the JSON files, as well as the extra commas noted above. I removed the commas and added the brackets, so now the crops load with the proper style i.e. crop/cross like the parent BlockCrops class. I also removed the // tags from all lines in the crop Block classes, so now each crop loads with the correct number of AGE values instead of taking on the value of the BlockCrops parent class, which was 7 instead of the 3/4 I wanted.

 

The textures still don't load properly, but the crops still work properly and have the correct number of ages registered. This line from the error log seems to be the problem:

 

Spoiler

[21:02:48] [Client thread/ERROR] [FML]: Exception loading model for variant fruitbushes:block_raspberry#inventory for item "fruitbushes:block_raspberry", normal location exception:

 

I've traced this back to the ModBlocks class, lines 67-69. It seems I don't actually have a render set up for the blocks, just the ItemBlocks? Am I interpreting that correctly? If so, how would I go about implementing the same method for blocks as I have for itemblocks but without the two conflicting? If I'm not interpreting that correctly, how would I go about altering the method so that it no longer requires the #inventory variable that seems unneeded?

 

Thanks

error log 11-08-19.txt

Link to comment
Share on other sites

I tried changing the "inventory" variable to null in ModBlocks and had the same problem, no textures. However, the error changed from

 

Spoiler

[21:02:48] [Client thread/ERROR] [FML]: Exception loading model for variant fruitbushes:block_raspberry#inventory for item "fruitbushes:block_raspberry", normal location exception:

 

to

 

Spoiler

[21:16:40] [Client thread/ERROR] [FML]: Exception loading model for variant fruitbushes:block_maloberry#normal for item "fruitbushes:block_maloberry", normal location exception:

 

So it's the same error, with a different variable set. Does this variable need to be called in the blockstates JSONs?

Link to comment
Share on other sites

6 hours ago, diesieben07 said:

You are telling Minecraft to load a model for your items that does not exist. Simple as that. It tells you where it tried to look and that it did not find anything there (which I can confirm is correct from looking at your repo).

 

Changing the variable from "inventory" to "age" in the ModBlocks class gives me the same error as well, shown below in the log. I can't remove the String from the method, as it requires a string. I'm not sure what else to try here.

 

Spoiler

[10:14:17] [Client thread/ERROR] [FML]: Exception loading model for variant fruitbushes:block_blueberry#age for item "fruitbushes:block_blueberry", normal location exception:
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model fruitbushes:item/block_blueberry with loader VanillaLoader.INSTANCE, skipping

 

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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