Deduplicate ingredient values in other constructor
This commit is contained in:
parent
96092c7189
commit
39a43398ba
|
|
@ -14,4 +14,16 @@ public class IngredientMixin {
|
||||||
private static Stream<? extends Ingredient.Value> injectDeduplicationPass(Stream<? extends Ingredient.Value> stream) {
|
private static Stream<? extends Ingredient.Value> injectDeduplicationPass(Stream<? extends Ingredient.Value> stream) {
|
||||||
return stream.map(IngredientValueDeduplicator::deduplicate);
|
return stream.map(IngredientValueDeduplicator::deduplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ModifyVariable(method = "<init>([Lnet/minecraft/world/item/crafting/Ingredient$Value;)V", at = @At("HEAD"), argsOnly = true, ordinal = 0)
|
||||||
|
private static Ingredient.Value[] injectDeduplicationPassArray(Ingredient.Value[] values) {
|
||||||
|
if (values.length == 0) {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
Ingredient.Value[] newValues = new Ingredient.Value[values.length];
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
newValues[i] = IngredientValueDeduplicator.deduplicate(values[i]);
|
||||||
|
}
|
||||||
|
return newValues;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class IngredientValueDeduplicator {
|
||||||
});
|
});
|
||||||
|
|
||||||
public static Ingredient.Value deduplicate(Ingredient.Value value) {
|
public static Ingredient.Value deduplicate(Ingredient.Value value) {
|
||||||
if (value.getClass() == Ingredient.ItemValue.class) {
|
if (value != null && value.getClass() == Ingredient.ItemValue.class) {
|
||||||
synchronized (VALUES) {
|
synchronized (VALUES) {
|
||||||
return VALUES.addOrGet((Ingredient.ItemValue)value);
|
return VALUES.addOrGet((Ingredient.ItemValue)value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user