mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
reformat code
This commit is contained in:
@@ -10,7 +10,7 @@ final class SelfDelegate implements BiomeDelegate {
|
||||
public static final SelfDelegate INSTANCE = new SelfDelegate();
|
||||
|
||||
private SelfDelegate() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ public class Vector3Int {
|
||||
this.z += z;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Vector3 toVector3() {
|
||||
return Vector3.of(x, y, z);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class BufferedWorld implements WritableWorld {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static final class Builder {
|
||||
private final WritableWorld delegate;
|
||||
private ReadInterceptor readInterceptor;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 -> {
|
||||
|
||||
@@ -27,7 +27,7 @@ public class InternalAddon implements BaseAddon {
|
||||
private static final Version VERSION = Versions.getVersion(1, 0, 0);
|
||||
|
||||
public InternalAddon() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
||||
logger.warn("""
|
||||
You are using Mohist, so we will not give you any support for issues that may arise.
|
||||
Since you enabled the "IKnowMohistCausesLotsOfIssuesButIWillUseItAnyways" flag, we won't disable Terra. But be warned.
|
||||
|
||||
|
||||
> I felt a great disturbance in the JVM, as if millions of plugins suddenly cried out in stack traces and were suddenly silenced.
|
||||
> I fear something terrible has happened.
|
||||
> - Astrash
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
@@ -40,6 +38,7 @@ import com.dfsek.terra.api.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.BukkitEntity;
|
||||
import com.dfsek.terra.bukkit.BukkitPlayer;
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.world.ServerWorld;
|
||||
import com.dfsek.terra.api.world.chunk.Chunk;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class BukkitChunk implements Chunk {
|
||||
private final org.bukkit.Chunk delegate;
|
||||
|
||||
@@ -27,11 +27,10 @@ import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||
|
||||
public class BukkitProtoWorld implements ProtoWorld {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BukkitProtoWorld.class);
|
||||
private static final AtomicBoolean warn = new AtomicBoolean(true);
|
||||
private final LimitedRegion delegate;
|
||||
private final BlockState air;
|
||||
|
||||
private static final AtomicBoolean warn = new AtomicBoolean(true);
|
||||
|
||||
public BukkitProtoWorld(LimitedRegion delegate, BlockState air) {
|
||||
this.delegate = delegate;
|
||||
this.air = air;
|
||||
@@ -122,7 +121,7 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
} else {
|
||||
LOGGER.debug("Detected world access at coordinates out of bounds: ({}, {}, {}) accessed for region [{}, {}]", x, y, z,
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
delegate.getCenterChunkX(), delegate.getCenterChunkZ());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -49,16 +49,16 @@ public class FabricEntryPoint implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
logger.info("Initializing Terra Fabric mod...");
|
||||
|
||||
|
||||
FabricServerCommandManager<CommandSender> manager = new FabricServerCommandManager<>(
|
||||
CommandExecutionCoordinator.simpleCoordinator(),
|
||||
serverCommandSource -> (CommandSender) serverCommandSource,
|
||||
commandSender -> (ServerCommandSource) commandSender
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
manager.brigadierManager().setNativeNumberSuggestions(false);
|
||||
|
||||
|
||||
TERRA_PLUGIN.getEventManager().callEvent(new CommandRegistrationEvent(manager));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,11 @@ import ca.solostudios.strata.version.Version;
|
||||
import com.dfsek.tectonic.api.TypeRegistry;
|
||||
import com.dfsek.tectonic.api.depth.DepthTracker;
|
||||
import com.dfsek.tectonic.api.exception.LoadException;
|
||||
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.MinecraftVersion;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome.Category;
|
||||
import net.minecraft.world.biome.Biome.Precipitation;
|
||||
import net.minecraft.world.biome.BiomeEffects.GrassColorModifier;
|
||||
@@ -53,6 +49,7 @@ import com.dfsek.terra.api.world.biome.PlatformBiome;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.fabric.handle.FabricItemHandle;
|
||||
import com.dfsek.terra.fabric.handle.FabricWorldHandle;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
import com.dfsek.terra.fabric.util.ProtoPlatformBiome;
|
||||
|
||||
|
||||
@@ -76,7 +73,7 @@ public class PlatformImpl extends AbstractPlatform {
|
||||
getTerraConfig().load(this);
|
||||
getRawConfigRegistry().clear();
|
||||
boolean succeed = getRawConfigRegistry().loadAll(this);
|
||||
|
||||
|
||||
|
||||
if(server != null) {
|
||||
server.reloadResources(server.getDataPackManager().getNames()).exceptionally(throwable -> {
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.structure.StructureSet;
|
||||
import net.minecraft.util.dynamic.RegistryOps;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryCodecs;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.chunk.ChunkGeneratorSettings;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
|
||||
@@ -20,11 +20,11 @@ package com.dfsek.terra.fabric.generation;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil.MultiNoiseSampler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
@@ -32,18 +32,14 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.fabric.data.Codecs;
|
||||
import com.dfsek.terra.fabric.util.ProtoPlatformBiome;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class TerraBiomeSource extends BiomeSource {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TerraBiomeSource.class);
|
||||
private final Registry<net.minecraft.world.biome.Biome> biomeRegistry;
|
||||
private final long seed;
|
||||
private ConfigPack pack;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TerraBiomeSource.class);
|
||||
|
||||
public TerraBiomeSource(Registry<net.minecraft.world.biome.Biome> biomes, long seed, ConfigPack pack) {
|
||||
super(StreamSupport
|
||||
.stream(pack.getBiomeProvider()
|
||||
@@ -73,7 +69,7 @@ public class TerraBiomeSource extends BiomeSource {
|
||||
.getBiomeProvider()
|
||||
.getBiome(biomeX << 2, biomeZ << 2, seed)
|
||||
.getPlatformBiome())
|
||||
.getDelegate());
|
||||
.getDelegate());
|
||||
}
|
||||
|
||||
public BiomeProvider getProvider() {
|
||||
|
||||
@@ -62,7 +62,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
}
|
||||
|
||||
public void terra$setDelay(int delay) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int terra$getMinSpawnDelay() {
|
||||
@@ -70,7 +70,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
}
|
||||
|
||||
public void terra$setMinSpawnDelay(int delay) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int terra$getMaxSpawnDelay() {
|
||||
@@ -78,7 +78,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
}
|
||||
|
||||
public void terra$setMaxSpawnDelay(int delay) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int terra$getSpawnCount() {
|
||||
@@ -86,7 +86,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
}
|
||||
|
||||
public void terra$setSpawnCount(int spawnCount) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int terra$getMaxNearbyEntities() {
|
||||
@@ -94,7 +94,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
}
|
||||
|
||||
public void terra$setMaxNearbyEntities(int maxNearbyEntities) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int terra$getRequiredPlayerRange() {
|
||||
@@ -102,7 +102,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
}
|
||||
|
||||
public void terra$setRequiredPlayerRange(int requiredPlayerRange) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int terra$getSpawnRange() {
|
||||
@@ -110,7 +110,7 @@ public abstract class MobSpawnerBlockEntityMixin extends BlockEntity {
|
||||
}
|
||||
|
||||
public void terra$setSpawnRange(int spawnRange) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void terra$applyState(String state) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.tick.MultiTickScheduler;
|
||||
import net.minecraft.world.tick.OrderedTick;
|
||||
import net.minecraft.world.tick.QueryableTickScheduler;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
@@ -69,7 +68,7 @@ public abstract class ChunkRegionMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private Chunk centerPos;
|
||||
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private MultiTickScheduler<Fluid> fluidTickScheduler;
|
||||
|
||||
@@ -17,15 +17,12 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.implementations.world;
|
||||
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Intrinsic;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -85,7 +82,8 @@ public abstract class ServerWorldMixin {
|
||||
}
|
||||
|
||||
public ChunkGenerator terra$getGenerator() {
|
||||
return ((FabricChunkGeneratorWrapper) ((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager().getChunkGenerator()).getHandle();
|
||||
return ((FabricChunkGeneratorWrapper) ((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager()
|
||||
.getChunkGenerator()).getHandle();
|
||||
}
|
||||
|
||||
public BiomeProvider terra$getBiomeProvider() {
|
||||
@@ -95,7 +93,8 @@ public abstract class ServerWorldMixin {
|
||||
}
|
||||
|
||||
public ConfigPack terra$getPack() {
|
||||
net.minecraft.world.gen.chunk.ChunkGenerator generator = (((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager()).getChunkGenerator();
|
||||
net.minecraft.world.gen.chunk.ChunkGenerator generator =
|
||||
(((net.minecraft.server.world.ServerWorld) (Object) this).getChunkManager()).getChunkGenerator();
|
||||
if(generator instanceof FabricChunkGeneratorWrapper fabricChunkGeneratorWrapper) {
|
||||
return fabricChunkGeneratorWrapper.getPack();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle;
|
||||
|
||||
import net.minecraft.server.DataPackContents;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.dfsek.terra.fabric.mixin.lifecycle;
|
||||
|
||||
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
@@ -17,28 +17,20 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.client;
|
||||
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.RunArgs;
|
||||
import net.minecraft.client.world.GeneratorType;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager.Mutable;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.generation.TerraGeneratorType;
|
||||
import com.dfsek.terra.fabric.mixin.access.GeneratorTypeAccessor;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.server;
|
||||
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
|
||||
import net.minecraft.server.dedicated.ServerPropertiesHandler;
|
||||
import net.minecraft.structure.StructureSet;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
@@ -38,6 +36,7 @@ import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.PlatformImpl;
|
||||
import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper;
|
||||
|
||||
@@ -17,30 +17,24 @@
|
||||
|
||||
package com.dfsek.terra.fabric.mixin.lifecycle.server;
|
||||
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
import net.minecraft.server.Main;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager;
|
||||
import net.minecraft.util.registry.DynamicRegistryManager.Mutable;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import com.dfsek.terra.api.event.events.platform.PlatformInitializationEvent;
|
||||
import com.dfsek.terra.fabric.FabricEntryPoint;
|
||||
import com.dfsek.terra.fabric.util.FabricUtil;
|
||||
|
||||
|
||||
@Mixin(Main.class)
|
||||
public class ServerMainMixin {
|
||||
@Inject(method = "main([Ljava/lang/String;)V",
|
||||
at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/resource/ResourcePackManager;<init>(Lnet/minecraft/resource/ResourceType;[Lnet/minecraft/resource/ResourcePackProvider;)V") // after registry manager creation
|
||||
target = "Lnet/minecraft/resource/ResourcePackManager;<init>(Lnet/minecraft/resource/ResourceType;" +
|
||||
"[Lnet/minecraft/resource/ResourcePackProvider;)V")
|
||||
// after registry manager creation
|
||||
)
|
||||
private static void injectConstructor(String[] args, CallbackInfo ci) {
|
||||
FabricEntryPoint.getPlatform().getEventManager().callEvent(
|
||||
|
||||
@@ -42,7 +42,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.entity.Container;
|
||||
@@ -57,6 +56,8 @@ import com.dfsek.terra.fabric.config.VanillaBiomeProperties;
|
||||
|
||||
public final class FabricUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FabricUtil.class);
|
||||
private static final Map<Identifier, List<Identifier>>
|
||||
TERRA_BIOME_MAP = new HashMap<>();
|
||||
|
||||
public static String createBiomeID(ConfigPack pack, com.dfsek.terra.api.registry.key.RegistryKey biomeID) {
|
||||
return pack.getID()
|
||||
@@ -71,10 +72,6 @@ public final class FabricUtil {
|
||||
});
|
||||
}
|
||||
|
||||
private static final Map<Identifier, List<Identifier>>
|
||||
TERRA_BIOME_MAP = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* Clones a Vanilla biome and injects Terra data to create a Terra-vanilla biome delegate.
|
||||
*
|
||||
@@ -95,16 +92,21 @@ public final class FabricUtil {
|
||||
Identifier identifier = new Identifier("terra", FabricUtil.createBiomeID(pack, id));
|
||||
|
||||
if(registry.containsId(identifier)) {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(FabricUtil.getEntry(registry, identifier).orElseThrow().getKey().orElseThrow());
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(FabricUtil.getEntry(registry, identifier)
|
||||
.orElseThrow()
|
||||
.getKey()
|
||||
.orElseThrow());
|
||||
} else {
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(BuiltinRegistries.add(registry, registerKey(identifier).getValue(), minecraftBiome).getKey().orElseThrow());
|
||||
((ProtoPlatformBiome) biome.getPlatformBiome()).setDelegate(BuiltinRegistries.add(registry,
|
||||
registerKey(identifier).getValue(),
|
||||
minecraftBiome).getKey().orElseThrow());
|
||||
}
|
||||
|
||||
TERRA_BIOME_MAP.computeIfAbsent(vanilla.getValue(), i -> new ArrayList<>()).add(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
private static RegistryKey<net.minecraft.world.biome.Biome> registerKey(Identifier identifier){
|
||||
private static RegistryKey<net.minecraft.world.biome.Biome> registerKey(Identifier identifier) {
|
||||
return RegistryKey.of(Registry.BIOME_KEY, identifier);
|
||||
}
|
||||
|
||||
@@ -130,9 +132,9 @@ public final class FabricUtil {
|
||||
tag -> collect
|
||||
.computeIfAbsent(tag, t -> new ArrayList<>())
|
||||
.add(getEntry(registry,
|
||||
terra.getKey()
|
||||
.orElseThrow()
|
||||
.getValue()).orElseThrow()));
|
||||
terra.getKey()
|
||||
.orElseThrow()
|
||||
.getValue()).orElseThrow()));
|
||||
|
||||
},
|
||||
() -> logger.error("No such biome: {}", tb))),
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.dfsek.terra.fabric.util;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryEntry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user