reformat code

This commit is contained in:
dfsek
2022-05-26 19:40:41 -07:00
parent 49857f6b91
commit ee373bbe4b
63 changed files with 214 additions and 242 deletions

View File

@@ -10,7 +10,7 @@ final class SelfDelegate implements BiomeDelegate {
public static final SelfDelegate INSTANCE = new SelfDelegate();
private SelfDelegate() {
}
@Override

View File

@@ -28,7 +28,7 @@ public class BiomePipelineTemplate extends BiomeProviderTemplate {
@Description("""
The initial size of biome chunks. This value must be at least 2.
<b>This is not the final size of biome chunks. Final chunks will be much larger</b>.
It is recommended to keep biome chunks' final size in the range of [50, 300]
to prevent performance issues. To calculate the size of biome chunks, simply
take initial-size and for each expand stage, multiply the running value by 2

View File

@@ -22,7 +22,7 @@ public class SlantHolder {
}
public static SlantHolder of(TreeMap<Double, PaletteHolder> layers, double minSlope) {
if(layers.size() == 1){
if(layers.size() == 1) {
Entry<Double, PaletteHolder> firstEntry = layers.firstEntry();
return new Single(firstEntry.getValue(), minSlope);
}
@@ -42,9 +42,9 @@ public class SlantHolder {
}
private static final class Single extends SlantHolder {
private final PaletteHolder layers;
public Single(PaletteHolder layers, double minSlope) {
super(of(minSlope, layers), minSlope);
this.layers = layers;
@@ -55,7 +55,7 @@ public class SlantHolder {
map.put(v, layer);
return map;
}
@Override
public PaletteHolder getPalette(double slope) {
return layers;

View File

@@ -34,12 +34,12 @@ public class PaddedGridDistributor implements Distributor {
public boolean matches(int x, int z, long seed) {
int cellX = FastMath.floorDiv(x, cellWidth);
int cellZ = FastMath.floorDiv(z, cellWidth);
Random random = new Random((murmur64(MathUtil.squash(cellX, cellZ)) ^ seed) + salt);
int pointX = random.nextInt(width) + cellX * cellWidth;
int pointZ = random.nextInt(width) + cellZ * cellWidth;
return x == pointX && z == pointZ;
}
}

View File

@@ -7,9 +7,10 @@
package com.dfsek.terra.addons.noise.normalizer;
import net.jafama.FastMath;
import com.dfsek.terra.api.noise.NoiseSampler;
import net.jafama.FastMath;
public class PosterizationNormalizer extends Normalizer {
private final double stepSize;

View File

@@ -22,6 +22,7 @@ public class GaborNoiseSampler extends NoiseFunction {
private double impulseDensity = (impulsesPerKernel / (Math.PI * kernelRadius * kernelRadius));
private double impulsesPerCell = impulseDensity * kernelRadius * kernelRadius;
private double g = FastMath.exp(-impulsesPerCell);
private double omega0 = Math.PI * 0.25;
private boolean isotropic = true;

View File

@@ -13,9 +13,6 @@ import ca.solostudios.strata.version.VersionRange;
import com.dfsek.tectonic.api.exception.LoadException;
import com.dfsek.tectonic.api.loader.ConfigLoader;
import com.dfsek.tectonic.yaml.YamlConfiguration;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,7 +20,6 @@ import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -41,6 +37,7 @@ import com.dfsek.terra.addons.manifest.impl.config.loaders.VersionRangeLoader;
import com.dfsek.terra.addons.manifest.impl.exception.AddonException;
import com.dfsek.terra.addons.manifest.impl.exception.ManifestException;
import com.dfsek.terra.addons.manifest.impl.exception.ManifestNotPresentException;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;

View File

@@ -12,7 +12,7 @@ public class Scope {
public Variable<?> get(String id) {
throw new IllegalStateException("Cannot get variable from null scope: " + id);
}
@Override
public void put(String id, Variable<?> variable) {
throw new IllegalStateException("Cannot set variable in null scope: " + id);
@@ -38,7 +38,7 @@ public class Scope {
public void put(String id, Variable<?> variable) {
variableMap.put(id, variable);
}
public Scope sub() {
return new Scope(this);

View File

@@ -7,13 +7,13 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.Scope;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public abstract class BinaryOperation<I, O> implements Returnable<O> {
private final Returnable<I> left;

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class BooleanAndOperation extends BinaryOperation<Boolean, Boolean> {
public BooleanAndOperation(Returnable<Boolean> left, Returnable<Boolean> right, Position start) {

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class BooleanOrOperation extends BinaryOperation<Boolean, Boolean> {
public BooleanOrOperation(Returnable<Boolean> left, Returnable<Boolean> right, Position start) {

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class ConcatenationOperation extends BinaryOperation<Object, Object> {
public ConcatenationOperation(Returnable<Object> left, Returnable<Object> right, Position position) {

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class DivisionOperation extends BinaryOperation<Number, Number> {
public DivisionOperation(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class ModuloOperation extends BinaryOperation<Number, Number> {
public ModuloOperation(Returnable<Number> left, Returnable<Number> right, Position start) {

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class MultiplicationOperation extends BinaryOperation<Number, Number> {
public MultiplicationOperation(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class NumberAdditionOperation extends BinaryOperation<Number, Number> {
public NumberAdditionOperation(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -7,11 +7,11 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class SubtractionOperation extends BinaryOperation<Number, Number> {
public SubtractionOperation(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -9,12 +9,12 @@ package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import net.jafama.FastMath;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
import static com.dfsek.terra.api.util.MathUtil.EPSILON;

View File

@@ -7,12 +7,12 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class GreaterOrEqualsThanStatement extends BinaryOperation<Number, Boolean> {
public GreaterOrEqualsThanStatement(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -7,12 +7,12 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class GreaterThanStatement extends BinaryOperation<Number, Boolean> {
public GreaterThanStatement(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -7,12 +7,12 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class LessThanOrEqualsStatement extends BinaryOperation<Number, Boolean> {
public LessThanOrEqualsStatement(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -7,12 +7,12 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import java.util.function.Supplier;
public class LessThanStatement extends BinaryOperation<Number, Boolean> {
public LessThanStatement(Returnable<Number> left, Returnable<Number> right, Position position) {

View File

@@ -7,14 +7,14 @@
package com.dfsek.terra.addons.terrascript.parser.lang.operations.statements;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import net.jafama.FastMath;
import java.util.function.Supplier;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
import com.dfsek.terra.addons.terrascript.parser.lang.operations.BinaryOperation;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import static com.dfsek.terra.api.util.MathUtil.EPSILON;
@@ -30,7 +30,7 @@ public class NotEqualsStatement extends BinaryOperation<Object, Boolean> {
if(leftUnwrapped instanceof Number l && rightUnwrapped instanceof Number r) {
return FastMath.abs(l.doubleValue() - r.doubleValue()) > EPSILON;
}
return !leftUnwrapped.equals(rightUnwrapped);
}

View File

@@ -47,7 +47,7 @@ public class EntityFunction implements Function<Void> {
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
Entity entity = arguments.getWorld().spawnEntity(Vector3.of(xz.getX(), y.apply(implementationArguments, scope).doubleValue(),
xz.getZ())
.mutable()

View File

@@ -36,9 +36,9 @@ public class GetMarkFunction implements Function<String> {
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
String mark = arguments.getMark(Vector3.of(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(
y.apply(implementationArguments, scope).doubleValue()),
y.apply(implementationArguments, scope).doubleValue()),
FastMath.floorToInt(xz.getZ()))
.mutable()
.add(arguments.getOrigin())

View File

@@ -38,8 +38,8 @@ public class SetMarkFunction implements Function<Void> {
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
arguments.setMark(Vector3.of(FastMath.floorToInt(xz.getX()),
FastMath.floorToInt(
y.apply(implementationArguments, scope).doubleValue()),

View File

@@ -43,8 +43,8 @@ public class StateFunction implements Function<Void> {
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
Vector3 origin = Vector3.of(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, scope).intValue(),
FastMath.roundToInt(xz.getZ())).mutable().add(arguments.getOrigin()).immutable();
try {

View File

@@ -60,11 +60,11 @@ public class StructureFunction implements Function<Boolean> {
if(arguments.getRecursions() > platform.getTerraConfig().getMaxRecursion())
throw new RuntimeException("Structure recursion too deep: " + arguments.getRecursions());
Vector2 xz = RotationUtil.rotateVector(Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
z.apply(implementationArguments, scope).doubleValue()), arguments.getRotation());
String app = id.apply(implementationArguments, scope);
return registry.getByID(app).map(script -> {
Rotation rotation1;

View File

@@ -4,8 +4,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
import com.dfsek.terra.addons.noise.config.DimensionApplicableNoiseSampler;
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
@@ -14,7 +12,6 @@ import com.dfsek.terra.addons.terrascript.parser.lang.constants.NumericConstant;
import com.dfsek.terra.addons.terrascript.parser.lang.constants.StringConstant;
import com.dfsek.terra.addons.terrascript.parser.lang.functions.FunctionBuilder;
import com.dfsek.terra.addons.terrascript.tokenizer.Position;
import com.dfsek.terra.api.noise.NoiseSampler;
public class SamplerFunctionBuilder implements FunctionBuilder<com.dfsek.terra.addons.terrascript.parser.lang.functions.Function<Number>> {
@@ -36,30 +33,36 @@ public class SamplerFunctionBuilder implements FunctionBuilder<com.dfsek.terra.a
@SuppressWarnings("unchecked")
@Override
public com.dfsek.terra.addons.terrascript.parser.lang.functions.Function<Number> build(List<Returnable<?>> argumentList, Position position) {
public com.dfsek.terra.addons.terrascript.parser.lang.functions.Function<Number> build(List<Returnable<?>> argumentList,
Position position) {
Returnable<String> arg = (Returnable<String>) argumentList.get(0);
if(argumentList.size() == 3) { // 2D
if(arg instanceof StringConstant constant) {
return new ConstantSamplerFunction(Objects.requireNonNull(samplers2d.get(constant.getConstant()), "No such 2D noise function " + constant.getConstant()).getSampler(),
(Returnable<Number>) argumentList.get(1),
new NumericConstant(0, position),
(Returnable<Number>) argumentList.get(2),
true,
position);
return new ConstantSamplerFunction(Objects.requireNonNull(samplers2d.get(constant.getConstant()),
"No such 2D noise function " + constant.getConstant())
.getSampler(),
(Returnable<Number>) argumentList.get(1),
new NumericConstant(0, position),
(Returnable<Number>) argumentList.get(2),
true,
position);
} else {
return new SamplerFunction((Returnable<String>) argumentList.get(0),
(Returnable<Number>) argumentList.get(1),
new NumericConstant(0, position),
(Returnable<Number>) argumentList.get(2),
s -> Objects.requireNonNull(samplers2d.get(s.get()), "No such 2D noise function " + s.get()).getSampler(),
s -> Objects.requireNonNull(samplers2d.get(s.get()), "No such 2D noise function " + s.get())
.getSampler(),
true,
position);
}
} else { // 3D
if(arg instanceof StringConstant constant) {
return new ConstantSamplerFunction(Objects.requireNonNull(samplers3d.get(constant.getConstant()), "No such 2D noise function " + constant.getConstant()).getSampler(),
return new ConstantSamplerFunction(Objects.requireNonNull(samplers3d.get(constant.getConstant()),
"No such 2D noise function " + constant.getConstant())
.getSampler(),
(Returnable<Number>) argumentList.get(1),
(Returnable<Number>) argumentList.get(2),
(Returnable<Number>) argumentList.get(3),
@@ -70,7 +73,8 @@ public class SamplerFunctionBuilder implements FunctionBuilder<com.dfsek.terra.a
(Returnable<Number>) argumentList.get(1),
(Returnable<Number>) argumentList.get(2),
(Returnable<Number>) argumentList.get(3),
s -> Objects.requireNonNull(samplers2d.get(s.get()), "No such 2D noise function " + s.get()).getSampler(),
s -> Objects.requireNonNull(samplers2d.get(s.get()), "No such 2D noise function " + s.get())
.getSampler(),
true,
position);
}

View File

@@ -105,7 +105,7 @@ public class BinaryColumn {
int smallMaxY = Math.min(this.maxY, that.maxY);
if(bigMinY >= smallMaxY) return getNull();
return new BinaryColumn(bigMinY, smallMaxY, y -> this.get(y) && that.get(y));
}

View File

@@ -131,35 +131,35 @@ public class Vector2 {
return "(" + x + ", " + z + ")";
}
public static class Mutable extends Vector2 {
private Mutable(double x, double z) {
super(x, z);
}
public double getX() {
return x;
}
public Mutable setX(double x) {
this.x = x;
return this;
}
public double getZ() {
return z;
}
public Mutable setZ(double z) {
this.z = z;
return this;
}
public Vector2 immutable() {
return Vector2.of(x, z);
}
/**
* Get the length of this Vector
*
@@ -168,7 +168,7 @@ public class Vector2 {
public double length() {
return FastMath.sqrt(lengthSquared());
}
/**
* Get the squared length of this Vector
*
@@ -177,13 +177,13 @@ public class Vector2 {
public double lengthSquared() {
return x * x + z * z;
}
public Mutable add(double x, double z) {
this.x += x;
this.z += z;
return this;
}
/**
* Multiply X and Z components by a value.
*
@@ -196,7 +196,7 @@ public class Vector2 {
z *= m;
return this;
}
/**
* Add this vector to another.
*
@@ -209,7 +209,7 @@ public class Vector2 {
z += other.getZ();
return this;
}
/**
* Subtract a vector from this vector,
*
@@ -222,7 +222,7 @@ public class Vector2 {
z -= other.getZ();
return this;
}
/**
* Normalize this vector to length 1
*
@@ -232,7 +232,7 @@ public class Vector2 {
divide(length());
return this;
}
/**
* Divide X and Z components by a value.
*

View File

@@ -91,7 +91,7 @@ public class Vector3 {
public double getY() {
return y;
}
public int getBlockX() {
return FastMath.floorToInt(x);
@@ -155,70 +155,70 @@ public class Vector3 {
return "(" + getX() + ", " + getY() + ", " + getZ() + ")";
}
public static class Mutable extends Vector3 {
private Mutable(double x, double y, double z) {
super(x, y, z);
}
public static Mutable of(double x, double y, double z) {
return new Mutable(x, y, z);
}
public Vector3 immutable() {
return Vector3.of(x, y, z);
}
public double getZ() {
return z;
}
public Mutable setZ(double z) {
this.z = z;
return this;
}
public double getX() {
return x;
}
public Mutable setX(double x) {
this.x = x;
return this;
}
public double getY() {
return y;
}
public Mutable setY(double y) {
this.y = y;
return this;
}
public double lengthSquared() {
return x * x + y * y + z * z;
}
public double length() {
return FastMath.sqrt(lengthSquared());
}
public double inverseLength() {
return FastMath.invSqrtQuick(lengthSquared());
}
public Mutable normalize() {
return this.multiply(this.inverseLength());
}
public Mutable subtract(int x, int y, int z) {
this.x -= x;
this.y -= y;
this.z -= z;
return this;
}
/**
* Calculates the dot product of this vector with another. The dot product
* is defined as x1*x2+y1*y2+z1*z2. The returned value is a scalar.
@@ -230,48 +230,48 @@ public class Vector3 {
public double dot(@NotNull Vector3 other) {
return x * other.getX() + y * other.getY() + z * other.getZ();
}
public Mutable subtract(Vector3 end) {
x -= end.getX();
y -= end.getY();
z -= end.getZ();
return this;
}
public Mutable multiply(double m) {
x *= m;
y *= m;
z *= m;
return this;
}
public Mutable add(double x, double y, double z) {
this.x += x;
this.y += y;
this.z += z;
return this;
}
public Mutable add(Vector3 other) {
this.x += other.getX();
this.y += other.getY();
this.z += other.getZ();
return this;
}
public Mutable add(Vector3Int other) {
this.x += other.getX();
this.y += other.getY();
this.z += other.getZ();
return this;
}
public Mutable add(Vector2 other) {
this.x += other.getX();
this.z += other.getZ();
return this;
}
/**
* Rotates the vector around a given arbitrary axis in 3 dimensional space.
*
@@ -297,7 +297,7 @@ public class Vector3 {
public Mutable rotateAroundAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException {
return rotateAroundNonUnitAxis(axis.isNormalized() ? axis : axis.mutable().normalize().immutable(), angle);
}
/**
* Rotates the vector around a given arbitrary axis in 3 dimensional space.
*
@@ -322,11 +322,11 @@ public class Vector3 {
public Mutable rotateAroundNonUnitAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException {
double x = getX(), y = getY(), z = getZ();
double x2 = axis.getX(), y2 = axis.getY(), z2 = axis.getZ();
double cosTheta = Math.cos(angle);
double sinTheta = Math.sin(angle);
double dotProduct = this.dot(axis);
double xPrime = x2 * dotProduct * (1d - cosTheta)
+ x * cosTheta
+ (-z2 * y + y2 * z) * sinTheta;
@@ -336,10 +336,10 @@ public class Vector3 {
double zPrime = z2 * dotProduct * (1d - cosTheta)
+ z * cosTheta
+ (-y2 * x + x2 * y) * sinTheta;
return setX(xPrime).setY(yPrime).setZ(zPrime);
}
/**
* Rotates the vector around the x axis.
* <p>
@@ -357,12 +357,12 @@ public class Vector3 {
public Mutable rotateAroundX(double angle) {
double angleCos = Math.cos(angle);
double angleSin = Math.sin(angle);
double y = angleCos * getY() - angleSin * getZ();
double z = angleSin * getY() + angleCos * getZ();
return setY(y).setZ(z);
}
/**
* Rotates the vector around the y axis.
* <p>
@@ -380,12 +380,12 @@ public class Vector3 {
public Mutable rotateAroundY(double angle) {
double angleCos = Math.cos(angle);
double angleSin = Math.sin(angle);
double x = angleCos * getX() + angleSin * getZ();
double z = -angleSin * getX() + angleCos * getZ();
return setX(x).setZ(z);
}
/**
* Rotates the vector around the z axis
* <p>
@@ -403,30 +403,30 @@ public class Vector3 {
public Mutable rotateAroundZ(double angle) {
double angleCos = Math.cos(angle);
double angleSin = Math.sin(angle);
double x = angleCos * getX() - angleSin * getY();
double y = angleSin * getX() + angleCos * getY();
return setX(x).setY(y);
}
@Override
public int hashCode() {
int hash = 13;
hash = 79 * hash + (int) (Double.doubleToLongBits(this.x) ^ (Double.doubleToLongBits(this.x) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.y) ^ (Double.doubleToLongBits(this.y) >>> 32));
hash = 79 * hash + (int) (Double.doubleToLongBits(this.z) ^ (Double.doubleToLongBits(this.z) >>> 32));
return hash;
}
public int getBlockX() {
return FastMath.floorToInt(x);
}
public int getBlockY() {
return FastMath.floorToInt(y);
}
public int getBlockZ() {
return FastMath.floorToInt(z);
}

View File

@@ -91,7 +91,7 @@ public class Vector3Int {
this.z += z;
return this;
}
public Vector3 toVector3() {
return Vector3.of(x, y, z);
}

View File

@@ -105,7 +105,7 @@ public class BufferedWorld implements WritableWorld {
return delegate;
}
public static final class Builder {
private final WritableWorld delegate;
private ReadInterceptor readInterceptor;

View File

@@ -72,20 +72,20 @@ public class Column<T extends WritableWorld> {
return (Column<T>) world.column(x + offsetX, z + offsetZ);
}
public static class BinaryColumnBuilder {
private final boolean[] arr;
private final Column<?> column;
public BinaryColumnBuilder(Column<?> column) {
this.column = column;
arr = new boolean[column.getMaxY() - column.getMinY()];
}
public BinaryColumn build() {
return new BinaryColumn(column.getMinY(), column.getMaxY(), arr);
}
public BinaryColumnBuilder set(int y) {
arr[y - column.getMinY()] = true;
return this;

View File

@@ -18,9 +18,6 @@
package com.dfsek.terra;
import com.dfsek.tectonic.api.TypeRegistry;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
@@ -49,6 +46,7 @@ import com.dfsek.terra.addon.EphemeralAddon;
import com.dfsek.terra.addon.InternalAddon;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.addon.BaseAddon;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.PluginConfig;
import com.dfsek.terra.api.event.EventManager;
@@ -153,26 +151,26 @@ public abstract class AbstractPlatform implements Platform {
protected InternalAddon loadAddons() {
List<BaseAddon> addonList = new ArrayList<>();
InternalAddon internalAddon = new InternalAddon();
addonList.add(internalAddon);
platformAddon().forEach(addonList::add);
BootstrapAddonLoader bootstrapAddonLoader = new BootstrapAddonLoader();
Path addonsFolder = getDataFolder().toPath().resolve("addons");
Injector<Platform> platformInjector = new InjectorImpl<>(this);
platformInjector.addExplicitTarget(Platform.class);
BootstrapAddonClassLoader bootstrapAddonClassLoader = new BootstrapAddonClassLoader(new URL[] {}, getClass().getClassLoader());
BootstrapAddonClassLoader bootstrapAddonClassLoader = new BootstrapAddonClassLoader(new URL[]{ }, getClass().getClassLoader());
bootstrapAddonLoader.loadAddons(addonsFolder, bootstrapAddonClassLoader)
.forEach(bootstrapAddon -> {
platformInjector.inject(bootstrapAddon);
bootstrapAddon.loadAddons(addonsFolder, bootstrapAddonClassLoader)
.forEach(addonList::add);
});
@@ -183,7 +181,7 @@ public abstract class AbstractPlatform implements Platform {
builder.append("Loading ")
.append(addonList.size())
.append(" Terra addons:");
for(BaseAddon addon : addonList) {
builder.append("\n ")
.append("- ")
@@ -191,10 +189,10 @@ public abstract class AbstractPlatform implements Platform {
.append("@")
.append(addon.getVersion().getFormatted());
}
logger.info(builder.toString());
}
DependencySorter sorter = new DependencySorter();
addonList.forEach(sorter::add);
sorter.sort().forEach(addon -> {

View File

@@ -27,7 +27,7 @@ public class InternalAddon implements BaseAddon {
private static final Version VERSION = Versions.getVersion(1, 0, 0);
public InternalAddon() {
}
@Override

View File

@@ -62,7 +62,7 @@ public class MetaListLikePreprocessor extends MetaPreprocessor<Meta> {
if(!s.startsWith("<< ")) continue;
String meta = s.substring(3);
Pair<Configuration, Object> pair = getMetaValue(meta, depthTracker);
Object metaValue = pair.getRight();

View File

@@ -67,7 +67,7 @@ public class MetaMapPreprocessor extends MetaPreprocessor<Meta> {
depthTracker);
}
newMap.putAll((Map<?, ?>) meta);
String configName;
if(pair.getLeft().getName() == null) {
configName = "Anonymous Configuration";

View File

@@ -44,7 +44,7 @@ public class MetaValuePreprocessor extends MetaPreprocessor<Meta> {
if(value.startsWith("$") // it's a meta value.
&& !value.startsWith("${")) { // it's not a meta string template.
Pair<Configuration, Object> pair = getMetaValue(value.substring(1), depthTracker);
String configName;
if(pair.getLeft().getName() == null) {
configName = "Anonymous Configuration";

View File

@@ -68,21 +68,21 @@ public class ProfilerImpl implements Profiler {
if(SAFE.get()) {
long time = System.nanoTime();
Stack<Frame> stack = THREAD_STACK.get();
Map<String, List<Long>> timingsMap = TIMINGS.get();
if(timingsMap.isEmpty()) {
synchronized(accessibleThreadMaps) {
accessibleThreadMaps.add(timingsMap);
}
}
Frame top = stack.pop();
if(!stack.isEmpty() ? !top.getId().endsWith("." + frame) : !top.getId().equals(frame))
throw new MalformedStackException("Expected " + frame + ", found " + top);
List<Long> timings = timingsMap.computeIfAbsent(top.getId(), id -> new ArrayList<>());
timings.add(time - top.getStart());
}
if(size.get() == 0) SAFE.set(true);

View File

@@ -38,11 +38,11 @@ import com.dfsek.terra.registry.OpenRegistryImpl;
*/
public class ConfigRegistry extends OpenRegistryImpl<ConfigPack> {
private static final Logger logger = LoggerFactory.getLogger(ConfigRegistry.class);
public ConfigRegistry() {
super(TypeKey.of(ConfigPack.class));
}
public void load(File folder, Platform platform) throws ConfigException {
ConfigPack pack = new ConfigPackImpl(folder, platform);
register(pack.getRegistryKey(), pack);

View File

@@ -60,11 +60,11 @@ public class ProfilerTest {
for(int i = 0; i < 100; i++) {
doThing();
}
for(int i = 0; i < 100; i++) {
doThirdOtherThing();
}
for(int i = 0; i < 100; i++) {
doOtherThing();
}
@@ -76,7 +76,7 @@ public class ProfilerTest {
PROFILER.pop("thing");
PROFILER.push("thing4");
PROFILER.pop("thing4");
PROFILER.getTimings().forEach((id, timings) -> System.out.println(id + ": " + timings.toString()));
}
}

View File

@@ -50,7 +50,7 @@ public class RegistryTest {
test.registerChecked(RegistryKey.parse("test:test"), "bazinga2");
fail("Shouldn't be able to re-register with #registerChecked!");
} catch(DuplicateEntryException ignore) {
}
}
@@ -66,7 +66,7 @@ public class RegistryTest {
test.register(RegistryKey.parse("test:test"), "bazinga2");
fail("Shouldn't be able to re-register in CheckedRegistry!");
} catch(DuplicateEntryException ignore) {
}
}
@@ -90,7 +90,7 @@ public class RegistryTest {
test.getByID("test");
fail("Shouldn't be able to get with ambiguous ID!");
} catch(IllegalArgumentException ignore) {
}
}
}

View File

@@ -19,14 +19,12 @@ package com.dfsek.terra.addon;
import ca.solostudios.strata.Versions;
import ca.solostudios.strata.version.Version;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -35,6 +33,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.dfsek.terra.addon.exception.AddonLoadException;
import com.dfsek.terra.api.addon.bootstrap.BootstrapAddonClassLoader;
import com.dfsek.terra.api.addon.bootstrap.BootstrapBaseAddon;