mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
switch terrascript items to use context
This commit is contained in:
1 parent
fb505fe28b
commit
373f6a5fe3
36 files changed
+119
-119
No files matched your search
+3
-3
@@ -2,10 +2,10 @@ package com.dfsek.terra.addons.terrascript.builders;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -29,8 +29,8 @@ public class BinaryNumberFunctionBuilder implements FunctionBuilder<Function<Num
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Number apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply(((Returnable<Number>) argumentList.get(0)).apply(implementationArguments, variableMap), ((Returnable<Number>) argumentList.get(1)).apply(implementationArguments, variableMap));
|
||||
public Number apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply(((Returnable<Number>) argumentList.get(0)).apply(, implementationArguments, variableMap), ((Returnable<Number>) argumentList.get(1)).apply(, implementationArguments, variableMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -2,11 +2,11 @@ package com.dfsek.terra.addons.terrascript.builders;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -30,8 +30,8 @@ public class UnaryBooleanFunctionBuilder implements FunctionBuilder<Function<Voi
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
function.accept(((Returnable<Boolean>) argumentList.get(0)).apply(implementationArguments, variableMap), (TerraImplementationArguments) implementationArguments);
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
function.accept(((Returnable<Boolean>) argumentList.get(0)).apply(, implementationArguments, variableMap), (TerraImplementationArguments) implementationArguments);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -2,10 +2,10 @@ package com.dfsek.terra.addons.terrascript.builders;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -28,8 +28,8 @@ public class UnaryNumberFunctionBuilder implements FunctionBuilder<Function<Numb
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Number apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply(((Returnable<Number>) argumentList.get(0)).apply(implementationArguments, variableMap));
|
||||
public Number apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply(((Returnable<Number>) argumentList.get(0)).apply(, implementationArguments, variableMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -2,10 +2,10 @@ package com.dfsek.terra.addons.terrascript.builders;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -28,8 +28,8 @@ public class UnaryStringFunctionBuilder implements FunctionBuilder<Function<Void
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
function.accept(((Returnable<String>) argumentList.get(0)).apply(implementationArguments, variableMap));
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
function.accept(((Returnable<String>) argumentList.get(0)).apply(, implementationArguments, variableMap));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@ package com.dfsek.terra.addons.terrascript.builders;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.FunctionBuilder;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -29,7 +29,7 @@ public class ZeroArgFunctionBuilder<T> implements FunctionBuilder<Function<T>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public T apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return function.apply((TerraImplementationArguments) implementationArguments);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -31,16 +31,16 @@ public class BiomeFunction implements Function<String> {
|
||||
|
||||
|
||||
@Override
|
||||
public String apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public String apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
BiomeProvider grid = arguments.getWorld().getBiomeProvider();
|
||||
|
||||
return grid.getBiome(arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ()))), arguments.getWorld().getSeed()).getID();
|
||||
return grid.getBiome(arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ()))), arguments.getWorld().getSeed()).getID();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+5
-4
@@ -10,6 +10,7 @@ import com.dfsek.terra.addons.terrascript.api.buffer.items.BufferedBlock;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -37,16 +38,16 @@ public class BlockFunction implements Function<Void> {
|
||||
}
|
||||
|
||||
void setBlock(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap, TerraImplementationArguments arguments, BlockState rot) {
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||
arguments.getBuffer().addItem(new BufferedBlock(rot, overwrite.apply(implementationArguments, variableMap), main, arguments.isWaterlog()), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())));
|
||||
arguments.getBuffer().addItem(new BufferedBlock(rot, overwrite.apply(, implementationArguments, variableMap), main, arguments.isWaterlog()), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
BlockState rot = getBlockState(implementationArguments, variableMap).clone();
|
||||
setBlock(implementationArguments, variableMap, arguments, rot);
|
||||
@@ -54,7 +55,7 @@ public class BlockFunction implements Function<Void> {
|
||||
}
|
||||
|
||||
protected BlockState getBlockState(ImplementationArguments arguments, Map<String, Variable<?>> variableMap) {
|
||||
return data.computeIfAbsent(blockData.apply(arguments, variableMap), main.getWorldHandle()::createBlockData);
|
||||
return data.computeIfAbsent(blockData.apply(, arguments, variableMap), main.getWorldHandle()::createBlockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -26,14 +26,14 @@ public class CheckBlockFunction implements Function<String> {
|
||||
|
||||
|
||||
@Override
|
||||
public String apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public String apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
String data = arguments.getWorld().getBlockData(arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())))).getAsString();
|
||||
String data = arguments.getWorld().getBlockData(arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())))).getAsString();
|
||||
if(data.contains("[")) return data.substring(0, data.indexOf('[')); // Strip properties
|
||||
else return data;
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,12 +1,12 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -31,17 +31,17 @@ public class CheckFunction implements Function<String> {
|
||||
|
||||
|
||||
@Override
|
||||
public String apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public String apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
|
||||
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
|
||||
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
Vector3 location = arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())));
|
||||
Vector3 location = arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ())));
|
||||
|
||||
return apply(location, arguments.getWorld());
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.exception.ParseException;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.ConstantExpression;
|
||||
@@ -11,6 +10,7 @@ import com.dfsek.terra.addons.terrascript.api.buffer.items.BufferedEntity;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -35,13 +35,13 @@ public class EntityFunction implements Function<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
arguments.getBuffer().addItem(new BufferedEntity(data, main), new Vector3(xz.getX(), y.apply(implementationArguments, variableMap).doubleValue(), xz.getZ()));
|
||||
arguments.getBuffer().addItem(new BufferedEntity(data, main), new Vector3(xz.getX(), y.apply(, implementationArguments, variableMap).doubleValue(), xz.getZ()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -25,12 +25,12 @@ public class GetMarkFunction implements Function<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public String apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
String mark = arguments.getBuffer().getMark(new Vector3(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())));
|
||||
String mark = arguments.getBuffer().getMark(new Vector3(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(, implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())));
|
||||
return mark == null ? "" : mark;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.StructureScript;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
@@ -9,6 +8,7 @@ import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.buffer.items.BufferedLootApplication;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
@@ -38,13 +38,13 @@ public class LootFunction implements Function<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
String id = data.apply(implementationArguments, variableMap);
|
||||
String id = data.apply(, implementationArguments, variableMap);
|
||||
LootTable table = registry.get(id);
|
||||
|
||||
if(table == null) {
|
||||
@@ -52,7 +52,7 @@ public class LootFunction implements Function<Void> {
|
||||
return null;
|
||||
}
|
||||
|
||||
arguments.getBuffer().addItem(new BufferedLootApplication(table, main, script), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||
arguments.getBuffer().addItem(new BufferedLootApplication(table, main, script), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.exception.ParseException;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.ConstantExpression;
|
||||
@@ -11,6 +10,7 @@ import com.dfsek.terra.addons.terrascript.api.buffer.items.BufferedPulledBlock;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -34,14 +34,14 @@ public class PullFunction implements Function<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
BlockState rot = data.clone();
|
||||
RotationUtil.rotateBlockData(rot, arguments.getRotation().inverse());
|
||||
arguments.getBuffer().addItem(new BufferedPulledBlock(rot), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||
arguments.getBuffer().addItem(new BufferedPulledBlock(rot), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,8 +25,8 @@ public class RandomFunction implements Function<Integer> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
return ((TerraImplementationArguments) implementationArguments).getRandom().nextInt(numberReturnable.apply(implementationArguments, variableMap).intValue());
|
||||
public Integer apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return ((TerraImplementationArguments) implementationArguments).getRandom().nextInt(numberReturnable.apply(, implementationArguments, variableMap).intValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class RecursionsFunction implements Function<Number> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Number apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Number apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
return ((TerraImplementationArguments) implementationArguments).getRecursions();
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,11 +1,11 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -27,13 +27,13 @@ public class SetMarkFunction implements Function<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
arguments.getBuffer().setMark(mark.apply(implementationArguments, variableMap), new Vector3(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())));
|
||||
arguments.getBuffer().setMark(mark.apply(, implementationArguments, variableMap), new Vector3(FastMath.floorToInt(xz.getX()), FastMath.floorToInt(y.apply(, implementationArguments, variableMap).doubleValue()), FastMath.floorToInt(xz.getZ())));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.buffer.items.BufferedStateManipulator;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -31,12 +31,12 @@ public class StateFunction implements Function<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Void apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
arguments.getBuffer().addItem(new BufferedStateManipulator(main, data.apply(implementationArguments, variableMap)), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||
arguments.getBuffer().addItem(new BufferedStateManipulator(main, data.apply(, implementationArguments, variableMap)), new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).intValue(), FastMath.roundToInt(xz.getZ())));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,13 +1,13 @@
|
||||
package com.dfsek.terra.addons.terrascript.functions;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.api.Function;
|
||||
import com.dfsek.terra.addons.terrascript.api.ImplementationArguments;
|
||||
import com.dfsek.terra.addons.terrascript.api.Position;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Returnable;
|
||||
import com.dfsek.terra.addons.terrascript.api.lang.Variable;
|
||||
import com.dfsek.terra.addons.terrascript.api.buffer.IntermediateBuffer;
|
||||
import com.dfsek.terra.addons.terrascript.api.TerraImplementationArguments;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
@@ -44,17 +44,17 @@ public class StructureFunction implements Function<Boolean> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean apply(ImplementationArguments implementationArguments, Map<String, Variable<?>> variableMap) {
|
||||
public Boolean apply(Context context, Map<String, Variable<?>> variableMap) {
|
||||
TerraImplementationArguments arguments = (TerraImplementationArguments) implementationArguments;
|
||||
|
||||
if(arguments.getRecursions() > main.getTerraConfig().getMaxRecursion())
|
||||
throw new RuntimeException("Structure recursion too deep: " + arguments.getRecursions());
|
||||
|
||||
Vector2 xz = new Vector2(x.apply(implementationArguments, variableMap).doubleValue(), z.apply(implementationArguments, variableMap).doubleValue());
|
||||
Vector2 xz = new Vector2(x.apply(, implementationArguments, variableMap).doubleValue(), z.apply(, implementationArguments, variableMap).doubleValue());
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
String app = id.apply(implementationArguments, variableMap);
|
||||
String app = id.apply(, implementationArguments, variableMap);
|
||||
Structure script = registry.get(app);
|
||||
if(script == null) {
|
||||
main.logger().severe("No such structure " + app);
|
||||
@@ -62,7 +62,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
}
|
||||
|
||||
Rotation rotation1;
|
||||
String rotString = rotations.get(arguments.getRandom().nextInt(rotations.size())).apply(implementationArguments, variableMap);
|
||||
String rotString = rotations.get(arguments.getRandom().nextInt(rotations.size())).apply(, implementationArguments, variableMap);
|
||||
try {
|
||||
rotation1 = Rotation.valueOf(rotString);
|
||||
} catch(IllegalArgumentException e) {
|
||||
@@ -70,7 +70,7 @@ public class StructureFunction implements Function<Boolean> {
|
||||
return null;
|
||||
}
|
||||
|
||||
Vector3 offset = new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ()));
|
||||
Vector3 offset = new Vector3(FastMath.roundToInt(xz.getX()), y.apply(, implementationArguments, variableMap).doubleValue(), FastMath.roundToInt(xz.getZ()));
|
||||
|
||||
return script.generate(new IntermediateBuffer(arguments.getBuffer(), offset), arguments.getWorld(), arguments.getRandom(), arguments.getRotation().rotate(rotation1), arguments.getRecursions() + 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user