Skip to content

Commit d5f9ff6

Browse files
committed
Version Bump and fixing methods
1 parent 7602ca7 commit d5f9ff6

File tree

3 files changed

+57
-59
lines changed

3 files changed

+57
-59
lines changed

common/src/main/kotlin/io/github/techtastic/cc_vs/apis/ExtendedShipAPI.kt

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import io.github.techtastic.cc_vs.ship.PhysTickEventHandler
99
import io.github.techtastic.cc_vs.ship.QueuedForcesApplier
1010
import io.github.techtastic.cc_vs.util.CCVSUtils.toVector
1111
import net.minecraft.server.level.ServerLevel
12+
import org.checkerframework.common.reflection.qual.NewInstance
1213
import org.joml.Quaterniond
1314
import org.joml.Quaterniondc
1415
import org.joml.Vector3d
@@ -27,71 +28,69 @@ class ExtendedShipAPI(private val api: IAPIEnvironment, ship: ServerShip, level:
2728
}
2829

2930
@LuaFunction
30-
fun applyInvariantForce(xForce: Double, yForce: Double, zForce: Double) {
31-
this.control.applyInvariantForce(Vector3d(xForce, yForce, zForce))
31+
fun applyInvariantForce(args: IArguments) {
32+
val newForce =
33+
if (args.count() == 1)
34+
args.getTable(0).toVector()
35+
else
36+
Vector3d(args.getDouble(0), args.getDouble(1), args.getDouble(2))
37+
this.control.applyInvariantForce(newForce)
3238
}
3339

3440
@LuaFunction
35-
fun applyInvariantForce(force: Map<*,*>) {
36-
val newVec = force.toVector()
37-
applyInvariantForce(newVec.x(), newVec.y(), newVec.z())
41+
fun applyInvariantTorque(args: IArguments) {
42+
val newTorque =
43+
if (args.count() == 1)
44+
args.getTable(0).toVector()
45+
else
46+
Vector3d(args.getDouble(0), args.getDouble(1), args.getDouble(2))
47+
this.control.applyInvariantTorque(newTorque)
3848
}
3949

4050
@LuaFunction
41-
fun applyInvariantTorque(xTorque: Double, yTorque: Double, zTorque: Double) {
42-
this.control.applyInvariantTorque(Vector3d(xTorque, yTorque, zTorque))
51+
fun applyInvariantForceToPos(args: IArguments) {
52+
val (newForce, newPos) =
53+
if (args.count() == 2)
54+
Pair(args.getTable(0).toVector(), args.getTable(1).toVector())
55+
else
56+
Pair(
57+
Vector3d(args.getDouble(0), args.getDouble(1), args.getDouble(2)),
58+
Vector3d(args.getDouble(3), args.getDouble(4), args.getDouble(5))
59+
)
60+
this.control.applyInvariantForceToPos(newForce, newPos)
4361
}
4462

4563
@LuaFunction
46-
fun applyInvariantTorque(torque: Map<*,*>) {
47-
val newVec = torque.toVector()
48-
applyInvariantForce(newVec.x(), newVec.y(), newVec.z())
64+
fun applyRotDependentForce(args: IArguments) {
65+
val newForce =
66+
if (args.count() == 1)
67+
args.getTable(0).toVector()
68+
else
69+
Vector3d(args.getDouble(0), args.getDouble(1), args.getDouble(2))
70+
this.control.applyRotDependentForce(newForce)
4971
}
5072

5173
@LuaFunction
52-
fun applyInvariantForceToPos(xForce: Double, yForce: Double, zForce: Double, xPos: Double, yPos: Double, zPos: Double) {
53-
this.control.applyInvariantForceToPos(Vector3d(xForce, yForce, zForce), Vector3d(xPos, yPos, zPos))
74+
fun applyRotDependentTorque(args: IArguments) {
75+
val newTorque =
76+
if (args.count() == 1)
77+
args.getTable(0).toVector()
78+
else
79+
Vector3d(args.getDouble(0), args.getDouble(1), args.getDouble(2))
80+
this.control.applyRotDependentTorque(newTorque)
5481
}
5582

5683
@LuaFunction
57-
fun applyInvariantForceToPos(force: Map<*,*>, pos: Map<*,*>) {
58-
val newForce = force.toVector()
59-
val newPos = pos.toVector()
60-
applyInvariantForceToPos(newForce.x(), newForce.y(), newForce.z(), newPos.x(), newPos.y(), newPos.z())
61-
}
62-
63-
@LuaFunction
64-
fun applyRotDependentForce(xForce: Double, yForce: Double, zForce: Double) {
65-
this.control.applyRotDependentForce(Vector3d(xForce, yForce, zForce))
66-
}
67-
68-
@LuaFunction
69-
fun applyRotDependentForce(force: Map<*,*>) {
70-
val newVec = force.toVector()
71-
applyRotDependentForce(newVec.x(), newVec.y(), newVec.z())
72-
}
73-
74-
@LuaFunction
75-
fun applyRotDependentTorque(xTorque: Double, yTorque: Double, zTorque: Double) {
76-
this.control.applyRotDependentTorque(Vector3d(xTorque, yTorque, zTorque))
77-
}
78-
79-
@LuaFunction
80-
fun applyRotDependentTorque(torque: Map<*,*>) {
81-
val newVec = torque.toVector()
82-
applyRotDependentTorque(newVec.x(), newVec.y(), newVec.z())
83-
}
84-
85-
@LuaFunction
86-
fun applyRotDependentForceToPos(xForce: Double, yForce: Double, zForce: Double, xPos: Double, yPos: Double, zPos: Double) {
87-
this.control.applyRotDependentForceToPos(Vector3d(xForce, yForce, zForce), Vector3d(xPos, yPos, zPos))
88-
}
89-
90-
@LuaFunction
91-
fun applyRotDependentForceToPos(force: Map<*,*>, pos: Map<*,*>) {
92-
val newForce = force.toVector()
93-
val newPos = pos.toVector()
94-
applyRotDependentForceToPos(newForce.x(), newForce.y(), newForce.z(), newPos.x(), newPos.y(), newPos.z())
84+
fun applyRotDependentForceToPos(args: IArguments) {
85+
val (newForce, newPos) =
86+
if (args.count() == 2)
87+
Pair(args.getTable(0).toVector(), args.getTable(1).toVector())
88+
else
89+
Pair(
90+
Vector3d(args.getDouble(0), args.getDouble(1), args.getDouble(2)),
91+
Vector3d(args.getDouble(3), args.getDouble(4), args.getDouble(5))
92+
)
93+
this.control.applyRotDependentForceToPos(newForce, newPos)
9594
}
9695

9796
@LuaFunction

common/src/main/kotlin/io/github/techtastic/cc_vs/apis/ShipAPI.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,13 @@ open class ShipAPI(val ship: ServerShip, val level: ServerLevel) : ILuaAPI {
8686
this.ship.transform.positionInWorld.toLua()
8787

8888
@LuaFunction
89-
fun transformPositionToWorld(x: Double, y: Double, z: Double): Map<String, Double> =
90-
this.ship.shipToWorld.transformPosition(Vector3d(x, y, z)).toLua()
91-
92-
@LuaFunction
93-
fun transformPositionToWorld(table: Map<*,*>): Map<String, Double> {
94-
val pos = table.toVector()
95-
96-
return transformPositionToWorld(pos.x(), pos.y(), pos.z())
89+
fun transformPositionToWorld(args: IArguments): Map<String, Double> {
90+
val pos =
91+
if (args.count() == 1)
92+
Vector3d(args.getTable(0).toVector())
93+
else
94+
Vector3d(args.getDouble(0), args.getDouble(1), args.getDouble(2))
95+
return this.ship.shipToWorld.transformPosition(pos).toLua()
9796
}
9897

9998
@LuaFunction

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M
22
# Identity
33
mod_name=cc_vs
44
mod_id=cc_vs
5-
mod_version=0.2.2
5+
mod_version=0.3.0
66
enabled_platforms=fabric,forge
77
archives_base_name=cc_vs
88
maven_group=io.github.techtastic

0 commit comments

Comments
 (0)