mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
Change Java whitespace handling in .editorconfig (#425)
* Change whitespace handling in .editorconfig * Reformat code * fix format error * Reformat code --------- Co-authored-by: Zoë Gidiere <duplexsys@protonmail.com>
This commit is contained in:
+22
-22
@@ -37,32 +37,32 @@ public class DistributorAddon implements AddonInitializer {
|
||||
};
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Distributor>>> distributorRegistry = event
|
||||
.getPack()
|
||||
.getOrCreateRegistry(DISTRIBUTOR_TOKEN);
|
||||
|
||||
distributorRegistry.register(addon.key("SAMPLER"), SamplerDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("POINTS"), PointSetDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("PADDED_GRID"), PaddedGridDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("AND"), AndDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("OR"), OrDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("XOR"), XorDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("YES"), YesDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("NO"), NoDistributorTemplate::new);
|
||||
|
||||
event.getPack()
|
||||
.applyLoader(Point.class, PointTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> {
|
||||
CheckedRegistry<Supplier<ObjectTemplate<Distributor>>> distributorRegistry = event
|
||||
.getPack()
|
||||
.getOrCreateRegistry(DISTRIBUTOR_TOKEN);
|
||||
|
||||
distributorRegistry.register(addon.key("SAMPLER"), SamplerDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("POINTS"), PointSetDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("PADDED_GRID"), PaddedGridDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("AND"), AndDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("OR"), OrDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("XOR"), XorDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("YES"), YesDistributorTemplate::new);
|
||||
distributorRegistry.register(addon.key("NO"), NoDistributorTemplate::new);
|
||||
|
||||
event.getPack()
|
||||
.applyLoader(Point.class, PointTemplate::new);
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
public class AndDistributorTemplate implements ObjectTemplate<Distributor>, ValidatedConfigTemplate {
|
||||
@Value("distributors")
|
||||
private @Meta List<@Meta Distributor> distributors;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
Distributor current = distributors.remove(0);
|
||||
@@ -31,7 +31,7 @@ public class AndDistributorTemplate implements ObjectTemplate<Distributor>, Vali
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ValidationException {
|
||||
if(distributors.isEmpty()) throw new ValidationException("AND Distributor must specify at least 1 distributor.");
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
public class OrDistributorTemplate implements ObjectTemplate<Distributor>, ValidatedConfigTemplate {
|
||||
@Value("distributors")
|
||||
private @Meta List<@Meta Distributor> distributors;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
Distributor current = distributors.remove(0);
|
||||
@@ -31,7 +31,7 @@ public class OrDistributorTemplate implements ObjectTemplate<Distributor>, Valid
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ValidationException {
|
||||
if(distributors.isEmpty()) throw new ValidationException("OR Distributor must specify at least 1 distributor.");
|
||||
|
||||
+3
-3
@@ -11,13 +11,13 @@ import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
public class PaddedGridDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
@Value("width")
|
||||
private @Meta int width;
|
||||
|
||||
|
||||
@Value("padding")
|
||||
private @Meta int padding;
|
||||
|
||||
|
||||
@Value("salt")
|
||||
private @Meta int salt;
|
||||
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
return new PaddedGridDistributor(width, padding, salt);
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
public class PointSetDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
@Value("points")
|
||||
private @Meta Set<@Meta Point> points;
|
||||
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
return new PointSetDistributor(points);
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public class SamplerDistributorTemplate implements ObjectTemplate<Distributor> {
|
||||
private @Meta double threshold = 0;
|
||||
@Value("sampler")
|
||||
private @Meta NoiseSampler noise;
|
||||
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
return new SamplerDistributor(noise, threshold);
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
public class XorDistributorTemplate implements ObjectTemplate<Distributor>, ValidatedConfigTemplate {
|
||||
@Value("distributors")
|
||||
private @Meta List<@Meta Distributor> distributors;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Distributor get() {
|
||||
Distributor current = distributors.remove(0);
|
||||
@@ -31,7 +31,7 @@ public class XorDistributorTemplate implements ObjectTemplate<Distributor>, Vali
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean validate() throws ValidationException {
|
||||
if(distributors.isEmpty()) throw new ValidationException("XOR Distributor must specify at least 1 distributor.");
|
||||
|
||||
+7
-7
@@ -8,27 +8,27 @@ import com.dfsek.terra.api.util.MathUtil;
|
||||
|
||||
public class PaddedGridDistributor implements Distributor {
|
||||
private final int width;
|
||||
|
||||
|
||||
private final int cellWidth;
|
||||
|
||||
|
||||
private final int salt;
|
||||
|
||||
|
||||
public PaddedGridDistributor(int width, int padding, int salt) {
|
||||
this.width = width;
|
||||
this.salt = salt;
|
||||
this.cellWidth = width + padding;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
int cellX = Math.floorDiv(x, cellWidth);
|
||||
int cellZ = Math.floorDiv(z, cellWidth);
|
||||
|
||||
|
||||
Random random = new Random((MathUtil.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;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,11 +15,11 @@ import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
|
||||
public class PointSetDistributor implements Distributor {
|
||||
private final Set<Point> points;
|
||||
|
||||
|
||||
public PointSetDistributor(Set<Point> points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
return points.contains(new Point(x, z));
|
||||
|
||||
+3
-3
@@ -13,14 +13,14 @@ import com.dfsek.terra.api.structure.feature.Distributor;
|
||||
|
||||
public class SamplerDistributor implements Distributor {
|
||||
private final NoiseSampler sampler;
|
||||
|
||||
|
||||
private final double threshold;
|
||||
|
||||
|
||||
public SamplerDistributor(NoiseSampler sampler, double threshold) {
|
||||
this.sampler = sampler;
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean matches(int x, int z, long seed) {
|
||||
return sampler.noise(seed, x, z) < threshold;
|
||||
|
||||
+6
-6
@@ -10,28 +10,28 @@ package com.dfsek.terra.addons.feature.distributor.util;
|
||||
public class Point {
|
||||
private final int x;
|
||||
private final int z;
|
||||
|
||||
|
||||
private final int hash;
|
||||
|
||||
|
||||
public Point(int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.hash = 31 * x + z;
|
||||
}
|
||||
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Point that)) return false;
|
||||
|
||||
+2
-2
@@ -16,10 +16,10 @@ import com.dfsek.terra.api.config.meta.Meta;
|
||||
public class PointTemplate implements ObjectTemplate<Point> {
|
||||
@Value("x")
|
||||
private @Meta int x;
|
||||
|
||||
|
||||
@Value("z")
|
||||
private @Meta int z;
|
||||
|
||||
|
||||
@Override
|
||||
public Point get() {
|
||||
return new Point(x, z);
|
||||
|
||||
Reference in New Issue
Block a user