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

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