mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-03 06:16:10 +00:00
Use seismic func for perf 2
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.config.noise.BiomeNoiseProperties;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ChunkInterpolator;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.interpolation.ElevationInterpolator;
|
||||
@@ -26,7 +28,7 @@ public class Sampler3D {
|
||||
}
|
||||
|
||||
public double sample(double x, double y, double z) {
|
||||
return interpolator.getNoise(x, y, z) + elevationInterpolator.getElevation((int) Math.round(x), (int) Math.round(z));
|
||||
return interpolator.getNoise(x, y, z) + elevationInterpolator.getElevation(FloatingPointFunctions.round(x), FloatingPointFunctions.round(z));
|
||||
}
|
||||
|
||||
public double sample(int x, int y, int z) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import com.dfsek.seismic.type.vector.Vector3;
|
||||
|
||||
@@ -44,9 +45,9 @@ public class BiomeFunction implements Function<String> {
|
||||
|
||||
return grid.getBiome(arguments.getOrigin().toFloat()
|
||||
.mutable()
|
||||
.add(Vector3.of((int) Math.round(xz.getX()),
|
||||
.add(Vector3.of(FloatingPointFunctions.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
(int) Math.round(xz.getZ()))).immutable(), arguments.getWorld().getSeed()).getID();
|
||||
FloatingPointFunctions.round(xz.getZ()))).immutable(), arguments.getWorld().getSeed()).getID();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import com.dfsek.seismic.type.vector.Vector3;
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -71,9 +70,9 @@ public class BlockFunction implements Function<Void> {
|
||||
Vector2 xz = Vector2.Mutable.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()).rotate(arguments.getRotation());
|
||||
try {
|
||||
Vector3.Mutable set = Vector3.of((int) Math.round(xz.getX()),
|
||||
Vector3.Mutable set = Vector3.of(FloatingPointFunctions.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope).doubleValue(),
|
||||
(int) Math.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat());
|
||||
FloatingPointFunctions.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat());
|
||||
BlockState current = arguments.getWorld().getBlockState(set);
|
||||
if(overwrite.apply(implementationArguments, scope) || current.isAir()) {
|
||||
arguments.getWorld().setBlockState(set, rot, physics.apply(implementationArguments, scope));
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import com.dfsek.seismic.type.vector.Vector3;
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Returnable;
|
||||
@@ -41,9 +40,9 @@ public class CheckBlockFunction implements Function<String> {
|
||||
String data = arguments.getWorld()
|
||||
.getBlockState(arguments.getOrigin().toFloat()
|
||||
.mutable()
|
||||
.add(Vector3.of((int) Math.round(xz.getX()),
|
||||
.add(Vector3.of(FloatingPointFunctions.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope)
|
||||
.doubleValue(), (int) Math.round(xz.getZ()))))
|
||||
.doubleValue(), FloatingPointFunctions.round(xz.getZ()))))
|
||||
.getAsString();
|
||||
if(data.contains("[")) return data.substring(0, data.indexOf('[')); // Strip properties
|
||||
else return data;
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import com.dfsek.seismic.type.vector.Vector3;
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -64,10 +63,10 @@ public class LootFunction implements Function<Void> {
|
||||
|
||||
registry.get(RegistryKey.parse(id))
|
||||
.ifPresentOrElse(table -> {
|
||||
Vector3 apply = Vector3.of((int) Math.round(xz.getX()),
|
||||
Vector3 apply = Vector3.of(FloatingPointFunctions.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope)
|
||||
.intValue(),
|
||||
(int) Math.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat()).immutable();
|
||||
FloatingPointFunctions.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat()).immutable();
|
||||
|
||||
try {
|
||||
BlockEntity data = arguments.getWorld().getBlockEntity(apply);
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import com.dfsek.seismic.type.vector.Vector3;
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.ImplementationArguments;
|
||||
@@ -44,8 +43,8 @@ public class PullFunction implements Function<Void> {
|
||||
Vector2 xz = Vector2.Mutable.of(x.apply(implementationArguments, scope).doubleValue(),
|
||||
z.apply(implementationArguments, scope).doubleValue()).rotate(arguments.getRotation());
|
||||
|
||||
Vector3.Mutable mutable = Vector3.of((int) Math.round(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
||||
(int) Math.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat());
|
||||
Vector3.Mutable mutable = Vector3.of(FloatingPointFunctions.round(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
||||
FloatingPointFunctions.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat());
|
||||
while(mutable.getY() > arguments.getWorld().getMinHeight()) {
|
||||
if(!arguments.getWorld().getBlockState(mutable).isAir()) {
|
||||
arguments.getWorld().setBlockState(mutable, data);
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import com.dfsek.seismic.type.vector.Vector3;
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -43,8 +42,8 @@ public class StateFunction implements Function<Void> {
|
||||
z.apply(implementationArguments, scope).doubleValue()).rotate(arguments.getRotation());
|
||||
|
||||
|
||||
Vector3 origin = Vector3.of((int) Math.round(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
||||
(int) Math.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat()).immutable();
|
||||
Vector3 origin = Vector3.of(FloatingPointFunctions.round(xz.getX()), y.apply(implementationArguments, scope).intValue(),
|
||||
FloatingPointFunctions.round(xz.getZ())).mutable().add(arguments.getOrigin().toFloat()).immutable();
|
||||
try {
|
||||
BlockEntity state = arguments.getWorld().getBlockEntity(origin);
|
||||
state.applyState(data.apply(implementationArguments, scope));
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addons.terrascript.script.functions;
|
||||
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
import com.dfsek.seismic.type.Rotation;
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import org.slf4j.Logger;
|
||||
@@ -77,17 +78,17 @@ public class StructureFunction implements Function<Boolean> {
|
||||
if(script instanceof StructureScript structureScript) {
|
||||
return structureScript.generate(arguments.getOrigin(),
|
||||
arguments.getWorld()
|
||||
.buffer((int) Math.round(xz.getX()),
|
||||
.buffer(FloatingPointFunctions.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
(int) Math.round(xz.getZ())),
|
||||
FloatingPointFunctions.round(xz.getZ())),
|
||||
arguments.getRandom(),
|
||||
arguments.getRotation().rotate(rotation1), arguments.getRecursions() + 1);
|
||||
}
|
||||
return script.generate(arguments.getOrigin(),
|
||||
arguments.getWorld()
|
||||
.buffer((int) Math.round(xz.getX()),
|
||||
.buffer(FloatingPointFunctions.round(xz.getX()),
|
||||
y.apply(implementationArguments, scope).intValue(),
|
||||
(int) Math.round(xz.getZ())),
|
||||
FloatingPointFunctions.round(xz.getZ())),
|
||||
arguments.getRandom(),
|
||||
arguments.getRotation().rotate(rotation1));
|
||||
}).orElseGet(() -> {
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
package com.dfsek.terra.addon.terrascript.check;
|
||||
|
||||
import com.dfsek.seismic.type.vector.Vector2;
|
||||
import com.dfsek.seismic.type.vector.Vector3;
|
||||
import com.dfsek.seismic.math.floatingpoint.FloatingPointFunctions;
|
||||
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.NoiseChunkGenerator3D;
|
||||
import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.SamplerProvider;
|
||||
@@ -45,8 +44,8 @@ public class CheckFunction implements Function<String> {
|
||||
z.apply(implementationArguments, scope).doubleValue()).rotate(arguments.getRotation());
|
||||
|
||||
Vector3 location = arguments.getOrigin().toFloat().mutable().add(
|
||||
Vector3.of((int) Math.round(xz.getX()), y.apply(implementationArguments, scope).doubleValue(),
|
||||
(int) Math.round(xz.getZ()))).immutable();
|
||||
Vector3.of(FloatingPointFunctions.round(xz.getX()), y.apply(implementationArguments, scope).doubleValue(),
|
||||
FloatingPointFunctions.round(xz.getZ()))).immutable();
|
||||
|
||||
return apply(location, arguments.getWorld());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user