Use seismic func for perf 2

This commit is contained in:
Zoë Gidiere
2025-06-28 15:47:02 -06:00
parent a06c6fd980
commit 77b1960757
9 changed files with 29 additions and 31 deletions

View File

@@ -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

View File

@@ -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));

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));

View File

@@ -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(() -> {