mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-16 22:01:07 +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:
+20
-20
@@ -25,60 +25,60 @@ import com.dfsek.terra.api.world.WritableWorld;
|
||||
public class CheckFunction implements Function<String> {
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
|
||||
|
||||
public CheckFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Position position) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String apply(ImplementationArguments implementationArguments, Scope scope) {
|
||||
|
||||
|
||||
|
||||
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
|
||||
|
||||
|
||||
|
||||
Vector2 xz = Vector2.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue());
|
||||
|
||||
z.apply(implementationArguments, scope).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
|
||||
Vector3 location = arguments.getOrigin().toVector3Mutable().add(
|
||||
Vector3.of((int) Math.round(xz.getX()), y.apply(implementationArguments, scope).doubleValue(),
|
||||
(int) Math.round(xz.getZ()))).immutable();
|
||||
|
||||
Vector3.of((int) Math.round(xz.getX()), y.apply(implementationArguments, scope).doubleValue(),
|
||||
(int) Math.round(xz.getZ()))).immutable();
|
||||
|
||||
return apply(location, arguments.getWorld());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ReturnType returnType() {
|
||||
return ReturnType.STRING;
|
||||
}
|
||||
|
||||
|
||||
private String apply(Vector3 vector, WritableWorld world) {
|
||||
int y = vector.getBlockY();
|
||||
if(y >= world.getMaxHeight() || y < 0) return "AIR";
|
||||
SamplerProvider cache = ((NoiseChunkGenerator3D) world.getGenerator()).samplerProvider();
|
||||
double comp = sample(vector.getX(), vector.getY(), vector.getZ(), cache, world);
|
||||
|
||||
|
||||
if(comp > 0) return "LAND"; // If noise val is greater than zero, location will always be land.
|
||||
|
||||
|
||||
//BiomeProvider provider = tw.getBiomeProvider();
|
||||
//TerraBiome b = provider.getBiome(vector.getBlockX(), vector.getBlockZ());
|
||||
|
||||
|
||||
/*if(vector.getY() > c.getSeaLevel())*/
|
||||
return "AIR"; // Above sea level
|
||||
//return "OCEAN"; // Below sea level
|
||||
}
|
||||
|
||||
|
||||
private double sample(double x, double y, double z, SamplerProvider cache, World world) {
|
||||
int cx = Math.floorDiv((int) x, 16);
|
||||
int cz = Math.floorDiv((int) z, 16);
|
||||
|
||||
+5
-5
@@ -17,23 +17,23 @@ import com.dfsek.terra.api.Platform;
|
||||
|
||||
public class CheckFunctionBuilder implements FunctionBuilder<CheckFunction> {
|
||||
private final Platform platform;
|
||||
|
||||
|
||||
public CheckFunctionBuilder(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public CheckFunction build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new CheckFunction((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1),
|
||||
(Returnable<Number>) argumentList.get(2), position);
|
||||
(Returnable<Number>) argumentList.get(2), position);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int argNumber() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Returnable.ReturnType getArgument(int position) {
|
||||
return switch(position) {
|
||||
|
||||
+10
-10
@@ -12,20 +12,20 @@ import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
public class TerraScriptCheckFunctionAddon implements AddonInitializer {
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
|
||||
@Inject
|
||||
private BaseAddon addon;
|
||||
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(1)
|
||||
.then(event -> {
|
||||
event.getPack().getOrCreateRegistry(FunctionBuilder.class).register(addon.key("check"),
|
||||
new CheckFunctionBuilder(platform));
|
||||
})
|
||||
.failThrough();
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(addon, ConfigPackPreLoadEvent.class)
|
||||
.priority(1)
|
||||
.then(event -> {
|
||||
event.getPack().getOrCreateRegistry(FunctionBuilder.class).register(addon.key("check"),
|
||||
new CheckFunctionBuilder(platform));
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user