mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
reformat all code
This commit is contained in:
@@ -14,10 +14,15 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
|
||||
public class Context {
|
||||
private final Map<Class<? extends Properties>, Properties> map = new HashMap<>();
|
||||
private final AtomicReference<Properties[]> list = new AtomicReference<>(new Properties[size.get()]);
|
||||
private static final AtomicInteger size = new AtomicInteger(0);
|
||||
private static final Map<Class<? extends Properties>, PropertyKey<?>> properties = new HashMap<>();
|
||||
private final Map<Class<? extends Properties>, Properties> map = new HashMap<>();
|
||||
private final AtomicReference<Properties[]> list = new AtomicReference<>(new Properties[size.get()]);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Properties> PropertyKey<T> create(Class<T> clazz) {
|
||||
return (PropertyKey<T>) properties.computeIfAbsent(clazz, c -> new PropertyKey<>(size.getAndIncrement(), clazz));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Properties> T get(Class<T> clazz) {
|
||||
@@ -33,11 +38,6 @@ public class Context {
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends Properties> PropertyKey<T> create(Class<T> clazz) {
|
||||
return (PropertyKey<T>) properties.computeIfAbsent(clazz, c -> new PropertyKey<>(size.getAndIncrement(), clazz));
|
||||
}
|
||||
|
||||
public <T extends Properties> Context put(PropertyKey<T> key, T properties) {
|
||||
list.updateAndGet(p -> {
|
||||
if(p.length == size.get()) return p;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.dfsek.terra.api.util.vector.Vector3Int;
|
||||
|
||||
public final class GeometryUtil {
|
||||
private GeometryUtil() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void sphere(Vector3Int origin, int radius, Consumer<Vector3Int> action) {
|
||||
|
||||
@@ -22,6 +22,11 @@ public final class Pair<L, R> {
|
||||
private final L left;
|
||||
private final R right;
|
||||
|
||||
private Pair(L left, R right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public static <L, R, T> Function<Pair<L, R>, Pair<T, R>> mapLeft(Function<L, T> function) {
|
||||
return pair -> of(function.apply(pair.left), pair.right);
|
||||
}
|
||||
@@ -54,11 +59,6 @@ public final class Pair<L, R> {
|
||||
return pair -> pair.left;
|
||||
}
|
||||
|
||||
private Pair(L left, R right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@Contract("_, _ -> new")
|
||||
public static <L1, R1> Pair<L1, R1> of(L1 left, R1 right) {
|
||||
return new Pair<>(left, right);
|
||||
@@ -96,55 +96,6 @@ public final class Pair<L, R> {
|
||||
return Objects.equals(this.left, that.left) && Objects.equals(this.right, that.right);
|
||||
}
|
||||
|
||||
public static class Mutable<L, R> {
|
||||
private L left;
|
||||
private R right;
|
||||
|
||||
private Mutable(L left, R right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Contract("_, _ -> new")
|
||||
public static <L1, R1> Pair.Mutable<L1, R1> of(L1 left, R1 right) {
|
||||
return new Mutable<>(left, right);
|
||||
}
|
||||
|
||||
@Contract("-> new")
|
||||
public Pair<L, R> immutable() {
|
||||
return Pair.of(left, right);
|
||||
}
|
||||
|
||||
public L getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(L left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public R getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(R right) {
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Mutable<?, ?> that)) return false;
|
||||
|
||||
return Objects.equals(this.left, that.left) && Objects.equals(this.right, that.right);
|
||||
}
|
||||
}
|
||||
|
||||
public Pair<L, R> apply(BiConsumer<L, R> consumer) {
|
||||
consumer.accept(this.left, this.right);
|
||||
return this;
|
||||
@@ -154,4 +105,54 @@ public final class Pair<L, R> {
|
||||
public String toString() {
|
||||
return String.format("{%s,%s}", left, right);
|
||||
}
|
||||
|
||||
|
||||
public static class Mutable<L, R> {
|
||||
private L left;
|
||||
private R right;
|
||||
|
||||
private Mutable(L left, R right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Contract("_, _ -> new")
|
||||
public static <L1, R1> Pair.Mutable<L1, R1> of(L1 left, R1 right) {
|
||||
return new Mutable<>(left, right);
|
||||
}
|
||||
|
||||
@Contract("-> new")
|
||||
public Pair<L, R> immutable() {
|
||||
return Pair.of(left, right);
|
||||
}
|
||||
|
||||
public L getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(L left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public R getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(R right) {
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(left, right);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Mutable<?, ?> that)) return false;
|
||||
|
||||
return Objects.equals(this.left, that.left) && Objects.equals(this.right, that.right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public interface BiomeProvider {
|
||||
}
|
||||
return new CachingBiomeProvider(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
default int resolution() {
|
||||
return 1;
|
||||
|
||||
@@ -30,12 +30,12 @@ public class CachingBiomeProvider implements BiomeProvider, Handle {
|
||||
.initialCapacity(98304)
|
||||
.maximumSize(98304) // 1 full chunk (high res)
|
||||
.build(vec -> delegate.getBiome(vec.x * res, vec.y * res, vec.z * res, vec.seed));
|
||||
|
||||
|
||||
this.baseCache = Caffeine
|
||||
.newBuilder()
|
||||
.maximumSize(256) // 1 full chunk (high res)
|
||||
.build(vec -> delegate.getBaseBiome(vec.x * res, vec.z * res, vec.seed));
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,6 +80,8 @@ public class CachingBiomeProvider implements BiomeProvider, Handle {
|
||||
return 31 * code + ((int) (seed ^ (seed >>> 32)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private record SeededVector2(int x, int z, long seed) {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Column<T extends WritableWorld> {
|
||||
this.max = max;
|
||||
this.min = min;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
|
||||
@@ -4,9 +4,9 @@ public final class Interceptors {
|
||||
private static final ReadInterceptor READ_THROUGH = ((x, y, z, world) -> world.getBlockState(x, y, z));
|
||||
private static final WriteInterceptor WRITE_THROUGH = ((x, y, z, block, world, physics) -> world.setBlockState(x, y, z, block,
|
||||
physics));
|
||||
|
||||
|
||||
private Interceptors() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static ReadInterceptor readThrough() {
|
||||
|
||||
@@ -86,17 +86,17 @@ public class ColumnTest {
|
||||
public int getMaxY() {
|
||||
return max;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public T get(int y) {
|
||||
return p.apply(y);
|
||||
|
||||
Reference in New Issue
Block a user