From 2d364c450c0313d96eefdbe8bd9e11dd5dd75d07 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Thu, 9 Jan 2025 16:09:39 +0100 Subject: [PATCH] Fix crash when passing any list to Ingr.with_items, Closes #1457 --- .../core/evaluate/OperatorBuilders.java | 9 +++------ .../core/evaluate/operator/CombinedOperator.java | 2 +- .../core/evaluate/operator/CurriedOperator.java | 2 +- .../core/evaluate/operator/OperatorRegistry.java | 2 +- .../core/evaluate/operator/PositionedOperator.java | 2 +- .../core/evaluate/operator/PredicateOperator.java | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/OperatorBuilders.java b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/OperatorBuilders.java index 7830d932c7b..1b97dff9eb7 100644 --- a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/OperatorBuilders.java +++ b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/OperatorBuilders.java @@ -22,11 +22,7 @@ import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent; import org.cyclops.integrateddynamics.api.evaluate.EvaluationException; import org.cyclops.integrateddynamics.api.evaluate.operator.IOperator; -import org.cyclops.integrateddynamics.api.evaluate.variable.IValue; -import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType; -import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeListProxy; -import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNumber; -import org.cyclops.integrateddynamics.api.evaluate.variable.IVariable; +import org.cyclops.integrateddynamics.api.evaluate.variable.*; import org.cyclops.integrateddynamics.api.ingredient.IIngredientComponentHandler; import org.cyclops.integrateddynamics.api.logicprogrammer.IConfigRenderPattern; import org.cyclops.integrateddynamics.core.evaluate.build.OperatorBuilder; @@ -550,7 +546,8 @@ public static , V extends IValue, T, M> List unwrapI if (list.getRawValue().getValueType() != componentHandler.getValueType()) { throw new EvaluationException(Component.translatable( L10NValues.VALUETYPE_ERROR_INVALIDLISTVALUETYPE, - list.getRawValue().getValueType(), componentHandler.getValueType())); + Component.translatable(componentHandler.getValueType().getTranslationKey()), + Component.translatable(list.getRawValue().getValueType().getTranslationKey()))); } List listTransformed = Lists.newArrayListWithExpectedSize(list.getRawValue().getLength()); for (V value : list.getRawValue()) { diff --git a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CombinedOperator.java b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CombinedOperator.java index 2a3e623c5fd..d3d042891db 100644 --- a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CombinedOperator.java +++ b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CombinedOperator.java @@ -414,7 +414,7 @@ public CombinedOperator deserialize(ValueDeseralizationContext valueDeseralizati } catch (ClassCastException e) { e.printStackTrace(); throw new EvaluationException(Component.translatable(L10NValues.VALUETYPE_ERROR_DESERIALIZE, - valueOperator, e.getMessage())); + valueOperator.toString(), e.getMessage())); } IOperator[] operators = new IOperator[list.size()]; for (int i = 0; i < list.size(); i++) { diff --git a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CurriedOperator.java b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CurriedOperator.java index 60869f507b4..4f33c23c2eb 100644 --- a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CurriedOperator.java +++ b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/CurriedOperator.java @@ -228,7 +228,7 @@ public CurriedOperator deserialize(ValueDeseralizationContext valueDeseralizatio } catch (ClassCastException e) { e.printStackTrace(); throw new EvaluationException(Component.translatable(L10NValues.VALUETYPE_ERROR_DESERIALIZE, - valueOperator, e.getMessage())); + valueOperator.toString(), e.getMessage())); } ListTag list = tag.getList("values", Tag.TAG_COMPOUND); IVariable[] variables = new IVariable[list.size()]; diff --git a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/OperatorRegistry.java b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/OperatorRegistry.java index bd921029027..5fef73e3f81 100644 --- a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/OperatorRegistry.java +++ b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/OperatorRegistry.java @@ -151,7 +151,7 @@ public IOperator deserialize(ValueDeseralizationContext valueDeseralizationConte IOperatorSerializer serializer = namedSerializers.get(serializerName); if (serializer == null) { throw new EvaluationException( - Component.translatable(L10NValues.OPERATOR_ERROR_NO_DESERIALIZER, value)); + Component.translatable(L10NValues.OPERATOR_ERROR_NO_DESERIALIZER, value.toString())); } return serializer.deserialize(valueDeseralizationContext, tag.get("value")); } diff --git a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PositionedOperator.java b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PositionedOperator.java index d5945c0d963..30ae092d77b 100644 --- a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PositionedOperator.java +++ b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PositionedOperator.java @@ -106,7 +106,7 @@ public PositionedOperator deserialize(ValueDeseralizationContext valueDeseraliza } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | ClassCastException | IllegalAccessException e) { e.printStackTrace(); throw new EvaluationException(Component.translatable(L10NValues.VALUETYPE_ERROR_DESERIALIZE, - value, e.getMessage())); + value.toString(), e.getMessage())); } } } diff --git a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PredicateOperator.java b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PredicateOperator.java index 3d1590ea1da..596c63483a5 100644 --- a/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PredicateOperator.java +++ b/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PredicateOperator.java @@ -92,7 +92,7 @@ public PredicateOperator, IValue> deserialize(ValueDeseraliza } catch (ClassCastException e) { e.printStackTrace(); throw new EvaluationException(Component.translatable(L10NValues.VALUETYPE_ERROR_DESERIALIZE, - value, e.getMessage())); + value.toString(), e.getMessage())); } } }