Sophisticated Backpacks

Sophisticated Backpacks

89M Downloads

Hardcoded JEI Recipes

Masquera1d opened this issue ยท 16 comments

commented

Hi, I wanted to bring attention to how you're directly adding the recipes for several items in your mod to JEI. When you attempt to remove the recipe through a datapack or CraftTweaker, the recipe will still show up in JEI, even though it doesn't exist anymore.

commented

this should be fixed in the latest release so I am going to close. In case that you run into any other issues feel free to reopen or ping me on discord.

commented

I will need examples of such recipes as from what I can see I am only adding recipes that are actually registered at the time. Potentially something isn't working in the code that the default recipes don't get cleared properly but more info is needed to figure out what's happening for you.

commented

Apologies, didn't mean to close it. New-ish to Github.

From what I've personally tested, the Iron, Gold, Diamond, and Netherite Backpack are not able to have their recipes deleted from JEI. Interestingly enough the standard backpack doesnt have this issue, though. Let me know if this isnt enough information, I'll do my best to get anything else.

commented

I need to understand what exactly you're doing and if you're actually sure those recipes are supposed to be removed - they have a different type and because i don't know crafttweaker perhaps it only removes recipes of vanilla types.
From what I can tell in code even if recipes get removed / replaced the correct ones should appear in JEI unless perhaps whatever removes/replaces them perhaps doesn't trigger even that is supposed to be triggered when recipes change.

commented

and perhaps check if you're not affected by this issue that was reported on CraftTweaker and is caused by issue in JEI that is only fixed in 1.18.2. CraftTweaker/CraftTweaker#1455

Which brings me to the next question that is what version are you even trying this on?

commented

Okay, let me see how I can answer all this...

As for what I'm doing, I'm essentially deleting the "default" recipes in your mod for the backpacks, and then replacing them with custom ones. It works fine on the default backpack, and this is what it looks like:

image

The issue comes into play with the higher tier backpacks, as well as the upgrades. Here's what they look like currently.

image

image

As you can see, the old recipes are still there, despite me deleting the old recipes entirely.

image

The actual version I'm attempting this on is 1.18.2.

commented

I had initially misread the code, so what I said in that screenshot was partly wrong, using datapacks should work for the upgrade recipes, but I don't think they would work for the dye recipes.

These recipes are hardcoded as they just use DyeColor:
https://github.com/P3pp3rF1y/SophisticatedBackpacks/blob/1.18.x/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/jei/SBPPlugin.java#L80

So unless I'm mistaken, those recipes will always appear in JEI, even if the recipe map was completely empty. (can be tested with a recipes.removeAll() call in a script)

As for these recipes:
https://github.com/P3pp3rF1y/SophisticatedBackpacks/blob/1.18.x/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/compat/jei/SBPPlugin.java#L81-L82

you're adding to those lists whenever those classes are instantiated https://github.com/P3pp3rF1y/SophisticatedBackpacks/blob/1.18.x/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/crafting/BackpackUpgradeRecipe.java#L25

what you should be doing instead is not storing a list at all and instead be querying the RecipeManager directly, as shown here:
https://github.com/mezz/JustEnoughItems/blob/1.18.1/src/main/java/mezz/jei/plugins/vanilla/crafting/VanillaRecipes.java#L30-L34
and here
https://github.com/SlimeKnights/TinkersConstruct/blob/1.18.2/src/main/java/slimeknights/tconstruct/plugin/jei/JEIPlugin.java#L156-L157

That way mods can change the recipes after datapacks have loaded them.

commented

That still doesn't answer the questions I had above

  • can you check that the Jei issue above isn't affecting you?
  • and are you sure that you are removing these recipes correctly as they are not of vanilla types?
commented

Considering I'm on the version that supposedly has the fix, and I've relaunched the game itself numerous times, I don't think its just the reload command being weird here.

I'm fairly certain I'm removing them correctly? I asked for help in the CT sever previously, and the logs do show that the recipes are actually being removed. Someone pointed out that you were manually adding the recipes so they wouldn't actually be removed if you used a datapack, or CT in this case.

image

commented

yes I am manually adding the recipes as otherwise you wouldn't see any in JEI given that they are special recipes that JEI doesn't display by default.
But what whoever suggested that didn't see is the fact that I also clear the collections with registered recipes on resource reload which as far as I know should be happening when tools remove / add recipes (well at least the resource reload is there for that reason as well as for others). So those recipes are "hardcoded" just in a sense of taking dynamically whatever recipes are registered at the moment of resource reload and showing them in JEI. as far as I know that works with KubeJS, but perhaps I need to be doing something different here? anyway without info on how to recreate I have no idea if there's anything to fix on my side.

commented

Would it help if I gave you the crafttweaker script thats actually changing these recipes? I don't mind giving info on how to recreate it, but I'm not sure what in particular I should provide for that.

commented

It may, I have never worked with crafttweaker, but can at least try and see what exactly it's doing there

commented

Huh, I honestly thought that was the case by default. Though I dont think its too big of a deal? I dont mind fixing it if im able to though

commented

from that script I can immediately tell you that the new recipes will "work" but only in a sense of crafting the higher tier backpack item, but all inventory will get lost as part of this crafting as they don't use the correct recipe type

commented

@jaredlll08 Thanks for the info, the reason I was adding to those lists during instantiation was to save time when world gets open so that I don't have to do the expensive lookups on recipeManager. and my understanding was that the reload will always happen after the recipes were modified. But I guess that understanding was wrong.

So I guess the only way is to actually do the expensive lookups (or potentially keep ids of the instantiated recipes and then only add those that actually are still in recipe manager)

I will make these changes for the next version.

And you are right about dye recipes those are hardcoded. I assumed that no one would want to change those recipes, but I can at least make changes to actually check if the recipe is still present when JEI loads.