mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-23 16:49:10 +00:00
reformat
This commit is contained in:
@@ -6,11 +6,6 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface BooleanProperty extends Property<Boolean> {
|
||||
@Override
|
||||
default Class<Boolean> getType() {
|
||||
return Boolean.class;
|
||||
}
|
||||
|
||||
static BooleanProperty of(String name) {
|
||||
return new BooleanProperty() {
|
||||
private static final Collection<Boolean> BOOLEANS = Arrays.asList(true, false);
|
||||
@@ -26,4 +21,9 @@ public interface BooleanProperty extends Property<Boolean> {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
default Class<Boolean> getType() {
|
||||
return Boolean.class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public interface EnumProperty<T extends Enum<T>> extends Property<T> {
|
||||
static <T extends Enum<T>> EnumProperty<T> of(String name, Class<T> clazz) {
|
||||
return new EnumProperty<T>() {
|
||||
private final Lazy<Collection<T>> constants = Lazy.of(() -> Arrays.asList(clazz.getEnumConstants()));
|
||||
|
||||
@Override
|
||||
public Class<T> getType() {
|
||||
return clazz;
|
||||
|
||||
@@ -8,11 +8,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface IntProperty extends Property<Integer> {
|
||||
@Override
|
||||
default Class<Integer> getType() {
|
||||
return Integer.class;
|
||||
}
|
||||
|
||||
static IntProperty of(String name, int min, int max) {
|
||||
return new IntProperty() {
|
||||
private final Collection<Integer> collection = Construct.construct(() -> {
|
||||
@@ -34,4 +29,9 @@ public interface IntProperty extends Property<Integer> {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
default Class<Integer> getType() {
|
||||
return Integer.class;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public enum Direction {
|
||||
case DOWN:
|
||||
return this;
|
||||
default:
|
||||
return rotations[(this.rotation + rotation.getDegrees()/90) % 4];
|
||||
return rotations[(this.rotation + rotation.getDegrees() / 90) % 4];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.meta.RegistryFactory;
|
||||
import com.dfsek.terra.api.registry.meta.RegistryHolder;
|
||||
import com.dfsek.terra.api.tectonic.LoaderHolder;
|
||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.util.seeded.BiomeProviderBuilder;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.generator.ChunkGeneratorProvider;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class LootPopulateEvent extends AbstractCancellable implements PackEvent, Cancellable {
|
||||
private final Container container;
|
||||
private LootTable table;
|
||||
private final ConfigPack pack;
|
||||
private final Structure structure;
|
||||
private LootTable table;
|
||||
|
||||
public LootPopulateEvent(Container container, LootTable table, ConfigPack pack, Structure structure) {
|
||||
this.container = container;
|
||||
|
||||
@@ -5,6 +5,30 @@ import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
public interface NoiseSampler {
|
||||
static NoiseSampler zero() {
|
||||
return new NoiseSampler() {
|
||||
@Override
|
||||
public double getNoise(double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoise(double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(int seed, double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(int seed, double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 2D noise at given position using current settings
|
||||
* <p>
|
||||
@@ -30,28 +54,4 @@ public interface NoiseSampler {
|
||||
double getNoiseSeeded(int seed, double x, double y);
|
||||
|
||||
double getNoiseSeeded(int seed, double x, double y, double z);
|
||||
|
||||
static NoiseSampler zero() {
|
||||
return new NoiseSampler() {
|
||||
@Override
|
||||
public double getNoise(double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoise(double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(int seed, double x, double y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseSeeded(int seed, double x, double y, double z) {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.function.Function;
|
||||
public interface RegistryFactory {
|
||||
/**
|
||||
* Create a generic OpenRegistry.
|
||||
*
|
||||
* @param <T> Type of registry.
|
||||
* @return New OpenRegistry
|
||||
*/
|
||||
@@ -18,8 +19,9 @@ public interface RegistryFactory {
|
||||
|
||||
/**
|
||||
* Create an OpenRegistry with custom {@link TypeLoader}
|
||||
*
|
||||
* @param loader Function to create loader.
|
||||
* @param <T> Type of registry.
|
||||
* @param <T> Type of registry.
|
||||
* @return New OpenRegistry.
|
||||
*/
|
||||
<T> OpenRegistry<T> create(Function<OpenRegistry<T>, TypeLoader<T>> loader);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structure;
|
||||
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
|
||||
public interface ConfiguredStructure {
|
||||
ProbabilityCollection<Structure> getStructure();
|
||||
|
||||
@@ -5,15 +5,16 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface LoaderHolder {
|
||||
<T> LoaderHolder applyLoader(Type type, TypeLoader<T> loader);
|
||||
|
||||
default <T> LoaderHolder applyLoader(Class<? extends T> type, TypeLoader<T> loader) {
|
||||
return applyLoader((Type) type, loader);
|
||||
}
|
||||
|
||||
<T> LoaderHolder applyLoader(Type type, TemplateProvider<ObjectTemplate<T>> loader);
|
||||
|
||||
default <T> LoaderHolder applyLoader(Class<? extends T> type, TemplateProvider<ObjectTemplate<T>> loader) {
|
||||
return applyLoader((Type) type, loader);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.dfsek.terra.api.transform.exception.TransformException;
|
||||
import java.util.Objects;
|
||||
|
||||
public interface Validator<T> {
|
||||
boolean validate(T value) throws TransformException;
|
||||
|
||||
static <T> Validator<T> notNull() {
|
||||
return Objects::nonNull;
|
||||
}
|
||||
|
||||
boolean validate(T value) throws TransformException;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -37,8 +37,6 @@ public final class RotationUtil {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static Axis getRotatedAxis(Axis orig, Rotation r) {
|
||||
Axis other = orig;
|
||||
final boolean shouldSwitch = r.equals(Rotation.CW_90) || r.equals(Rotation.CCW_90);
|
||||
|
||||
@@ -11,6 +11,10 @@ public final class Lazy<T> {
|
||||
this.valueSupplier = valueSupplier;
|
||||
}
|
||||
|
||||
public static <T> Lazy<T> of(Supplier<T> valueSupplier) {
|
||||
return new Lazy<>(valueSupplier);
|
||||
}
|
||||
|
||||
public T value() {
|
||||
if(!got && value == null) {
|
||||
got = true;
|
||||
@@ -18,8 +22,4 @@ public final class Lazy<T> {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static <T> Lazy<T> of(Supplier<T> valueSupplier) {
|
||||
return new Lazy<>(valueSupplier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class ImmutablePair<L, R> {
|
||||
private static final ImmutablePair<?, ?> NULL = new ImmutablePair<>(null, null);
|
||||
private final L left;
|
||||
private final R right;
|
||||
|
||||
private static final ImmutablePair<?, ?> NULL = new ImmutablePair<>(null, null);
|
||||
|
||||
private ImmutablePair(L left, R right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
@@ -21,6 +20,12 @@ public final class ImmutablePair<L, R> {
|
||||
return new ImmutablePair<>(left, right);
|
||||
}
|
||||
|
||||
@Contract("-> new")
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <L1, R1> ImmutablePair<L1, R1> ofNull() {
|
||||
return (ImmutablePair<L1, R1>) NULL;
|
||||
}
|
||||
|
||||
public R getRight() {
|
||||
return right;
|
||||
}
|
||||
@@ -29,12 +34,6 @@ public final class ImmutablePair<L, R> {
|
||||
return left;
|
||||
}
|
||||
|
||||
@Contract("-> new")
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <L1, R1> ImmutablePair<L1, R1> ofNull() {
|
||||
return (ImmutablePair<L1, R1>) NULL;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Contract("-> new")
|
||||
public Pair<L, R> mutable() {
|
||||
|
||||
@@ -3,11 +3,6 @@ package com.dfsek.terra.api.util.seeded;
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
|
||||
public interface NoiseSeeded extends SeededBuilder<NoiseSampler> {
|
||||
@Override
|
||||
NoiseSampler apply(Long seed);
|
||||
|
||||
int getDimensions();
|
||||
|
||||
static NoiseSeeded zero(int dimensions) {
|
||||
return new NoiseSeeded() {
|
||||
@Override
|
||||
@@ -21,4 +16,9 @@ public interface NoiseSeeded extends SeededBuilder<NoiseSampler> {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
NoiseSampler apply(Long seed);
|
||||
|
||||
int getDimensions();
|
||||
}
|
||||
|
||||
@@ -30,6 +30,11 @@ public class Vector2 implements Cloneable {
|
||||
return x;
|
||||
}
|
||||
|
||||
public Vector2 setX(double x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector2 clone() {
|
||||
try {
|
||||
return (Vector2) super.clone();
|
||||
@@ -38,11 +43,6 @@ public class Vector2 implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 setX(double x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Z component
|
||||
*
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.api.vector;
|
||||
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.world.ChunkAccess;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
public interface Carver {
|
||||
void carve(World world, int chunkX, int chunkZ, ChunkAccess chunk);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ public interface ChunkAccess extends Handle {
|
||||
* <p>
|
||||
* Setting blocks outside the chunk's bounds does nothing.
|
||||
*
|
||||
* @param x the x location in the chunk from 0-15 inclusive
|
||||
* @param y the y location in the chunk from 0 (inclusive) - maxHeight (exclusive)
|
||||
* @param z the z location in the chunk from 0-15 inclusive
|
||||
* @param x the x location in the chunk from 0-15 inclusive
|
||||
* @param y the y location in the chunk from 0 (inclusive) - maxHeight (exclusive)
|
||||
* @param z the z location in the chunk from 0-15 inclusive
|
||||
* @param blockState the type to set the block to
|
||||
*/
|
||||
void setBlock(int x, int y, int z, @NotNull BlockState blockState);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.api.world;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.api.world.biome;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
public interface Generator {
|
||||
/**
|
||||
@@ -30,6 +29,7 @@ public interface Generator {
|
||||
double getWeight();
|
||||
|
||||
PaletteSettings getPaletteSettings();
|
||||
|
||||
NoiseSampler getBiomeNoise();
|
||||
|
||||
double getElevationWeight();
|
||||
|
||||
Reference in New Issue
Block a user