|
@@ -2,9 +2,11 @@ package me.km.snuviscript.commands;
|
|
|
|
|
|
import me.hammerle.snuviscript.code.ScriptManager;
|
|
|
import me.km.utils.Location;
|
|
|
+import me.km.utils.LocationIterator;
|
|
|
import me.km.world.WorldManager;
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
import net.minecraft.util.math.MathHelper;
|
|
|
+import net.minecraft.world.IWorld;
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
public class LocationCommands {
|
|
@@ -26,9 +28,11 @@ public class LocationCommands {
|
|
|
sm.registerFunction("loc.getx", (sc, in) -> ((Location) in[0].get(sc)).getX());
|
|
|
sm.registerFunction("loc.gety", (sc, in) -> ((Location) in[0].get(sc)).getY());
|
|
|
sm.registerFunction("loc.getz", (sc, in) -> ((Location) in[0].get(sc)).getZ());
|
|
|
+ sm.registerConsumer("loc.set", (sc, in) -> ((Location) in[0].get(sc)).set(in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc)));
|
|
|
sm.registerConsumer("loc.setx", (sc, in) -> ((Location) in[0].get(sc)).setX(in[1].getDouble(sc)));
|
|
|
sm.registerConsumer("loc.sety", (sc, in) -> ((Location) in[0].get(sc)).setY(in[1].getDouble(sc)));
|
|
|
sm.registerConsumer("loc.setz", (sc, in) -> ((Location) in[0].get(sc)).setZ(in[1].getDouble(sc)));
|
|
|
+ sm.registerConsumer("loc.add", (sc, in) -> ((Location) in[0].get(sc)).add(in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc)));
|
|
|
sm.registerConsumer("loc.addx", (sc, in) -> ((Location) in[0].get(sc)).addX(in[1].getDouble(sc)));
|
|
|
sm.registerConsumer("loc.addy", (sc, in) -> ((Location) in[0].get(sc)).addY(in[1].getDouble(sc)));
|
|
|
sm.registerConsumer("loc.addz", (sc, in) -> ((Location) in[0].get(sc)).addZ(in[1].getDouble(sc)));
|
|
@@ -87,5 +91,39 @@ public class LocationCommands {
|
|
|
l2.setZ(tmp);
|
|
|
}
|
|
|
});
|
|
|
+ sm.registerFunction("loc.iterator", (sc, in) -> {
|
|
|
+ return new LocationIterator((IWorld) in[0].get(sc),
|
|
|
+ in[1].getInt(sc), in[2].getInt(sc), in[3].getInt(sc),
|
|
|
+ in[4].getInt(sc), in[5].getInt(sc), in[6].getInt(sc));
|
|
|
+ });
|
|
|
+ sm.registerFunction("loc.trace", (sc, in) -> {
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ IWorld w = l.getWorld();
|
|
|
+ double x = l.getX();
|
|
|
+ double y = l.getY();
|
|
|
+ double z = l.getZ();
|
|
|
+ BlockPos.Mutable pos = new BlockPos.Mutable(x, y, z);
|
|
|
+ double ux = in[1].getDouble(sc);
|
|
|
+ double uy = in[2].getDouble(sc);
|
|
|
+ double uz = in[3].getDouble(sc);
|
|
|
+ int steps = in[4].getInt(sc);
|
|
|
+ boolean last = in[5].getBoolean(sc);
|
|
|
+ for(int i = 0; i < steps; i++) {
|
|
|
+ if(!w.isAirBlock(pos)) {
|
|
|
+ if(last) {
|
|
|
+ x -= ux;
|
|
|
+ y -= uy;
|
|
|
+ z -= uz;
|
|
|
+ }
|
|
|
+ l.set(x, y, z);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ x += ux;
|
|
|
+ y += uy;
|
|
|
+ z += uz;
|
|
|
+ pos.setPos(x, y, z);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ });
|
|
|
}
|
|
|
}
|