Jump to content

[1.12.1] Registering a shaped recipe crashes on world load


Aarilight

Recommended Posts

	@SubscribeEvent
	public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
		Souls.logger.info("register recipes");

		ItemStack recipeOutput = new ItemStack(ModObjects.ENDERSTEEL_BARS.getItemBlock(), 16);

		GameRegistry.addShapedRecipe(new ResourceLocation(Souls.MODID, "endersteel_bars.recipe"), null, recipeOutput,
				new String[] { "EEE", "EEE" }, 'E', ModObjects.ENDERSTEEL.getItem());
	}

This code doesn't crash when it's called, but it completely freezes the game on loading a world. Here's the log:

 

[16:21:10] [Server thread/FATAL] [FML]: Fatal errors were detected during the transition from AVAILABLE to SERVER_ABOUT_TO_START. Loading cannot continue
[16:21:10] [Server thread/FATAL] [FML]:
       States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

     | State   | ID        | Version            | Source                           | Signature |
    |:------- |:--------- |:------------------ |:-------------------------------- |:--------- |
    | UCHIJAA | minecraft | 1.12.1             | minecraft.jar                    | None      |
    | UCHIJAA | mcp       | 9.19               | minecraft.jar                    | None      |
    | UCHIJAA | FML       | 8.0.99.99          | forgeSrc-1.12.1-14.22.0.2462.jar | None      |
    | UCHIJAE | forge     | 14.22.0.2462       | forgeSrc-1.12.1-14.22.0.2462.jar | None      |
    | UCHIJAA | souls     | 1.12.1-5.1-87ac678 | Souls-1.12.1-5.1-87ac678.jar     | None      |

[16:21:10] [Server thread/FATAL] [FML]: The following problems were captured during this phase
[16:21:10] [Server thread/ERROR] [FML]: Caught exception from forge (java.lang.NullPointerException)
[16:21:10] [Server thread/ERROR] [FML]: A fatal exception occurred during the server about to start event
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Minecraft Forge (forge)

Caused by: java.lang.NullPointerException
        at net.minecraft.client.util.SearchTree.lambda$index$0(SearchTree.java:91) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
       at java.util.ArrayList.forEach(ArrayList.java:1249) ~[?:1.8.0_131-1-redhat]
    at net.minecraft.client.util.SearchTree.index(SearchTree.java:89) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
        at net.minecraft.client.util.SearchTree.add(SearchTree.java:78) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
  at java.util.ArrayList.forEach(ArrayList.java:1249) ~[?:1.8.0_131-1-redhat]
    at net.minecraft.client.Minecraft.populateSearchTreeManager(Minecraft.java:648) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
  at net.minecraftforge.fml.client.FMLClientHandler.reloadSearchTrees(FMLClientHandler.java:1107) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
  at net.minecraftforge.fml.common.FMLCommonHandler.reloadSearchTrees(FMLCommonHandler.java:771) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
   at net.minecraftforge.common.ForgeModContainer.mappingChanged(ForgeModContainer.java:535) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131-1-redhat]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131-1-redhat]
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131-1-redhat]
       at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131-1-redhat]
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[guava-21.0.jar:?]
        at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[guava-21.0.jar:?]
        at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[guava-21.0.jar:?]
 at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[guava-21.0.jar:?]
  at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[guava-21.0.jar:?]
 at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[guava-21.0.jar:?]
   at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[guava-21.0.jar:?]
     at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:253) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
 at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:231) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
   at net.minecraftforge.fml.common.Loader.fireRemapEvent(Loader.java:962) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
  at net.minecraftforge.registries.GameData.freezeData(GameData.java:233) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
  at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:790) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
  at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:343) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
      at net.minecraft.client.Minecraft.init(Minecraft.java:576) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
       at net.minecraft.client.Minecraft.run(Minecraft.java:416) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
        at net.minecraft.client.main.Main.main(Main.java:118) ~[forgeSrc-1.12.1-14.22.0.2462.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131-1-redhat]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131-1-redhat]
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131-1-redhat]
       at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131-1-redhat]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) ~[launchwrapper-1.12.jar:?]
      at net.minecraft.launchwrapper.Launch.main(Launch.java:28) ~[launchwrapper-1.12.jar:?]
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131-1-redhat]
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131-1-redhat]
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131-1-redhat]
       at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131-1-redhat]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) ~[GradleStartCommon.class:?]
  at GradleStart.main(GradleStart.java:26) ~[GradleStart.class:?]
[16:21:10] [Server thread/INFO]: Stopping server
[16:21:10] [Server thread/INFO]: Saving players
[16:21:10] [Server thread/INFO]: Saving worlds
[16:21:10] [Server thread/INFO] [FML]: Applying holder lookups
[16:21:10] [Server thread/INFO] [FML]: Holder lookups applied
[16:21:10] [Server thread/INFO] [FML]: The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED. Errors may have been discarded.
[16:21:10] [Server thread/INFO] [FML]: The state engine was in incorrect state ERRORED and forced into state AVAILABLE. Errors may have been discarded.

 

This freeze happens regardless of whether I register the recipe with GameRegistry.addShapedRecipe orForgeRegistries.RECIPES.register(new ShapedOreRecipe) 

What am I doing wrong?

Edited by Aarilight
simplify code
Link to comment
Share on other sites

1) Use JSON not in code.

2) Your items are invalid.

3) What the hell is this:

		List<Object> args = new ArrayList<>();
		args.addAll(Arrays.asList(recipe));
		args.addAll(Arrays.asList(map));

It's a varargs, you don't need to do any of that crap...

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Ah yea I should have simplified it for this post. The reason I was doing it like that is a mixture of old code and trying to figure out exactly what the problem is. 

 

You said my items are invalid, what's invalid about them? If I don't register this recipe the items seem to work fine, including in shapeless recipes.

Edited by Aarilight
Link to comment
Share on other sites

Not sure, something in the depths of building the search tree is hitting your items and nulling out.

Try debugging your code... See whats null in that exception.

But again, STOP using code to register recipes.

  • Like 1

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

I'm only using a simple recipe for testing, the recipes I'm actually using code for are much more complicated, things I don't expect I'll be able to do with the json format. I'll take a look when I get to converting the recipes to json, I just haven't gotten that far yet because of misc other conversion bugs.

 

I guess it's about time I use an IDE that supports debugging java...... it'll probably help me solve issues like this way easier >.> (I use VSCode for web-dev, just didn't want to spend the time configuring IDEA again--lost all my settings on a crash last time)

 

Anyway, thanks for the help. I'll keep forging ahead.

Edited by Aarilight
Link to comment
Share on other sites

35 minutes ago, Aarilight said:

I'm only using a simple recipe for testing, the recipes I'm actually using code for are much more complicated, things I don't expect I'll be able to do with the json format. I'll take a look when I get to converting the recipes to json, 

Ya, if you cant do it with json you're using the json wrong.

And that isn't hyperbole, the json can LITERALLY do everything code can.

Its just a matter of if it's intended to do that or not.

If you find a case where you cant do something let us know and we can expand the functionality, that's kinda the point of Forge.

 

37 minutes ago, Aarilight said:

I guess it's about time I use an IDE that supports debugging java...... it'll probably help me solve issues like this way easier >.>

People don't make IDEs for shits and giggles, they are really powerful tools...

  • Like 1

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

2 hours ago, LexManos said:

If you find a case where you cant do something let us know and we can expand the functionality, that's kinda the point of Forge.

Sure @LexManos, here's one. It's not recipes, its advancements, but still, it's something JSON cannot do currently (requires reflection hacking to register new ICriterionTriggers):

  • Like 1

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

I figured out the reason this was crashing, my recipe output item was never registered. The json recipe system warned about it on parsing. I guess it's kinda pointless to add in checks for that since it's heavily encouraged to use json recipes now.

 

(not related, but grats on 10k draco!)

Link to comment
Share on other sites

You should always register your items and use configs to make them craftable or not.

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

I didn't neglect to register the item on purpose >.> It was just a bug--I have two different superclasses for Blocks and BlockPanes and I had forgotten to register the BlockPanes on my Register<Block> event. ....When I get a chance I think I'll make an interface for these so that having separate superclasses isn't an issue I have to worry about anymore.

Edited by Aarilight
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.