fixed some Equation#asString related stuff

This commit is contained in:
CreepyCre 2022-05-23 00:31:22 +02:00
parent 47a96f87f7
commit be4696aee5
4 changed files with 11 additions and 6 deletions

View file

@ -286,7 +286,7 @@ public interface Equation {
stringBuilder.append(","); stringBuilder.append(",");
argumentEquations[i].visit(stringBuilder); argumentEquations[i].visit(stringBuilder);
} }
return stringBuilder.append(functionString); return stringBuilder.append(")");
})); }));
} }
} }

View file

@ -75,10 +75,12 @@ public abstract class PocketGenerator implements Weighted<PocketGenerationContex
} catch (EquationParseException e) { } catch (EquationParseException e) {
LOGGER.error("Could not parse weight equation \"" + weight + "\", defaulting to default weight equation \"" + defaultWeightEquation + "\"", e); LOGGER.error("Could not parse weight equation \"" + weight + "\", defaulting to default weight equation \"" + defaultWeightEquation + "\"", e);
try { try {
this.weightEquation = Equation.parse(defaultWeightEquation); // FIXME: do we actually want to have it serialize to the broken String equation we input?
this.weightEquation = Equation.newEquation(Equation.parse(defaultWeightEquation)::apply, stringBuilder -> stringBuilder.append(weight));
} catch (EquationParseException equationParseException) { } catch (EquationParseException equationParseException) {
LOGGER.error("Could not parse default weight equation \"" + defaultWeightEquation + "\", defaulting to fallback weight \"" + fallbackWeight + "\"", equationParseException); LOGGER.error("Could not parse default weight equation \"" + defaultWeightEquation + "\", defaulting to fallback weight \"" + fallbackWeight + "\"", equationParseException);
this.weightEquation = stringDoubleMap -> fallbackWeight; // FIXME: do we actually want to have it serialize to the broken String equation we input?
this.weightEquation = Equation.newEquation(stringDoubleMap -> (double) fallbackWeight, stringBuilder -> stringBuilder.append(weight));
} }
} }
} }

View file

@ -222,7 +222,8 @@ public class ShellModifier implements LazyModifier {
this.thicknessEquation = Equation.parse(thickness); this.thicknessEquation = Equation.parse(thickness);
} catch (Equation.EquationParseException e) { } catch (Equation.EquationParseException e) {
LOGGER.error("Could not parse layer thickness equation. Defaulting to 1"); LOGGER.error("Could not parse layer thickness equation. Defaulting to 1");
this.thicknessEquation = variableMap -> 1d; // FIXME: do we actually want to have it serialize to the broken String equation we input?
this.thicknessEquation = Equation.newEquation(variableMap -> 1d, stringBuilder -> stringBuilder.append(thickness));
} }
this.blockState = SchematicBlockPalette.Entry.to(blockStateString).getOrThrow(false, LOGGER::error); this.blockState = SchematicBlockPalette.Entry.to(blockStateString).getOrThrow(false, LOGGER::error);

View file

@ -46,11 +46,13 @@ public abstract class PocketGeneratorReference implements ImplementedVirtualPock
LOGGER.debug("Defaulting to default weight equation for {}", this); LOGGER.debug("Defaulting to default weight equation for {}", this);
LOGGER.debug("Exception Stacktrace", e); LOGGER.debug("Exception Stacktrace", e);
try { try {
this.weightEquation = Equation.parse(DimensionalDoorsInitializer.getConfig().getPocketsConfig().defaultWeightEquation); // FIXME: do we actually want to have it serialize to the broken String equation we input?
this.weightEquation = Equation.newEquation(Equation.parse(DimensionalDoorsInitializer.getConfig().getPocketsConfig().defaultWeightEquation)::apply, stringBuilder -> stringBuilder.append(weight));
} catch (EquationParseException equationParseException) { } catch (EquationParseException equationParseException) {
LOGGER.debug("Defaulting to default weight equation for {}", this); LOGGER.debug("Defaulting to default weight equation for {}", this);
LOGGER.debug("Exception Stacktrace", e); LOGGER.debug("Exception Stacktrace", e);
this.weightEquation = stringDoubleMap -> DimensionalDoorsInitializer.getConfig().getPocketsConfig().fallbackWeight; // FIXME: do we actually want to have it serialize to the broken String equation we input?
this.weightEquation = Equation.newEquation(stringDoubleMap -> (double) DimensionalDoorsInitializer.getConfig().getPocketsConfig().fallbackWeight, stringBuilder -> stringBuilder.append(weight));
} }
} }
} }