Fix issues with custom forge ingredients causing sub ingredients to be prematurely and invalidly cached (#8550)

Add config option and skip checking for empty ingredients in shapeless recipe deserialization
This commit is contained in:
Sara Freimer authored and GitHub committed 2022-04-08 15:37:43 -07:00
1 parent 1e6845669c
commit fbaf92105e
6 files changed
+20 -3

No files matched your search

@@ -56,3 +56,12 @@
} else {
ItemStack itemstack = ShapedRecipe.m_151274_(GsonHelper.m_13930_(p_44291_, "result"));
return new ShapelessRecipe(p_44290_, s, itemstack, nonnulllist);
@@ -88,7 +_,7 @@
for(int i = 0; i < p_44276_.size(); ++i) {
Ingredient ingredient = Ingredient.m_43917_(p_44276_.get(i));
- if (!ingredient.m_43947_()) {
+ if (net.minecraftforge.common.ForgeConfig.SERVER.skipEmptyShapelessCheck.get() || !ingredient.m_43947_()) {
nonnulllist.add(ingredient);
}
}
@@ -27,6 +27,7 @@ public class ForgeConfig {
public final DoubleValue zombieBabyChance;
public final BooleanValue treatEmptyTagsAsAir;
public final BooleanValue skipEmptyShapelessCheck;
public final BooleanValue fixAdvancementLoading;
@@ -65,6 +66,11 @@ public class ForgeConfig {
.translation("forge.configgui.treatEmptyTagsAsAir")
.define("treatEmptyTagsAsAir", false);
skipEmptyShapelessCheck = builder
.comment("Skip checking if an ingredient is empty during shapeless recipe deserialization to prevent complex ingredients from caching tags too early.")
.translation("forge.configgui.skipEmptyShapelessCheck")
.define("skipEmptyShapelessCheck", true);
fixAdvancementLoading = builder
.comment("Fix advancement loading to use a proper topological sort. This may have visibility side-effects and can thus be turned off if needed for data-pack compatibility.")
.translation("forge.configgui.fixAdvancementLoading")
@@ -156,7 +156,7 @@ public class CompoundIngredient extends AbstractIngredient
@Override
public boolean isEmpty()
{
return getItems().length == 0;
return children.stream().allMatch(Ingredient::isEmpty);
}
public static class Serializer implements IIngredientSerializer<CompoundIngredient>
@@ -64,7 +64,7 @@ public class DifferenceIngredient extends AbstractIngredient
@Override
public boolean isEmpty()
{
return getItems().length == 0;
return base.isEmpty();
}
@Override
@@ -91,7 +91,7 @@ public class IntersectionIngredient extends AbstractIngredient
@Override
public boolean isEmpty()
{
return getItems().length == 0;
return children.stream().anyMatch(Ingredient::isEmpty);
}
@Override
@@ -153,6 +153,8 @@
"forge.configgui.clumpingThreshold": "Packet Clumping Threshold",
"forge.configgui.treatEmptyTagsAsAir.tooltip": "Vanilla will treat crafting recipes using empty tags as air, and allow you to craft with nothing in that slot. This changes empty tags to use BARRIER as the item. To prevent crafting with air.",
"forge.configgui.treatEmptyTagsAsAir": "Treat empty tags as air",
"forge.configgui.skipEmptyShapelessCheck.tooltip": "Skip checking if an ingredient is empty during shapeless recipe deserialization to prevent complex ingredients from caching tags too early.",
"forge.configgui.skipEmptyShapelessCheck": "Skip checking for empty ingredients in Shapeless Recipe Deserialization",
"forge.configgui.forceSystemNanoTime.tooltip": "Force the use of System.nanoTime instead of glfwGetTime as the main client Time provider.",
"forge.configgui.forceSystemNanoTime": "Force System.nanoTime",