Jump to content

[1.16.3] NBT Crafting


MagnusWright

Recommended Posts

I want to create a mod that allows you to craft a written book with a banner, similar to shields, to put the pattern on the cover of the book. However, the only information I can find on crafting recipes involving NBT data relies on creating an IRecipe and IRecipeFactory, the latter of which doesn't seem to exist in 1.16.3. I've looked to ShieldRecipes for inspiration and I've written a class that I think might work, but I've got no idea how to register the recipe. Once I've implemented IRecipe, how do I register it so I can actually test it in game?

Link to comment
Share on other sites

If my serializer only serializes one recipe, can I just put the type in the JSON and return the recipe from the read functions like this?

{
  "type": "literature:coveredbook"
}

 

public static class CoveredBookRecipeSerializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<CoveredBookRecipe> {
	@Override
	public CoveredBookRecipe read(ResourceLocation recipeId, JsonObject json) {
		return new CoveredBookRecipe(recipeId);
	}

	@Override
	public CoveredBookRecipe read(ResourceLocation recipeId, PacketBuffer buffer) {
		return new CoveredBookRecipe(recipeId);
	}

	@Override
	public void write(PacketBuffer buffer, CoveredBookRecipe recipe) {
		
	}
}

 

Link to comment
Share on other sites

My recipe doesn't seem to do anything. I see in the log that the serializer gets registered and I don't see any errors logged, but when I try to craft a written book with a banner nothing happens. I already caught a couple of simple mistakes like forgetting to actually register the serializer and misspelling the resource folder, so I won't be surprised if whatever I'm doing wrong now is equally simple but I still don't totally know what I'm looking at.
https://github.com/Deadbeetle/literature-mod

Link to comment
Share on other sites

I actually had it in `data` originally but I moved it to assets because it didn't work and I wasn't sure if that was the right place (moving it back to data didn't fix it). As for using a data generator, the file is so small that writing it by hand was faster, but I'll probably do that if (or when) I end up needing more JSON files later.

Link to comment
Share on other sites

OK so for some insane reason I used "literaturemod" for the modid in the recipe file, when the actual modid is "literature". I must have changed my mind about what to use for the modid at some point, or something like that. Anyways, the recipe actually gets called now, so I could determine that the "empty" slots in the crafting inventory are in fact filled with air, so my matches function was returning false. Now that I've accounted for that, the recipe actually does work the way I intended.

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.