this doesnt work and i dont know why this isnt working
1.20.1 forge
Code-
(// Get all ships in range
try {
for (Ship ship : VSGameUtilsKt.getShipsIntersecting(level,
new AABB(corePos.offset(-searchRadius, -searchRadius, -searchRadius),
corePos.offset(searchRadius, searchRadius, searchRadius)))) {
// Calculate distance from core to ship center
Vector3dc shipCenter = ship.getTransform().getPositionInWorld();
Vector3d coreWorldPos = new Vector3d(
corePos.getX() + 0.5,
corePos.getY() + 0.5,
corePos.getZ() + 0.5
);
double distance = coreWorldPos.distance(shipCenter);
// Only affect ships within our radius
if (distance > searchRadius) continue;
// Calculate gravity force (stronger when closer)
double forceStrength = Math.max(0.1, (searchRadius - distance) * 0.5);
// Apply gravity force toward the core
Vector3d gravityDirection = new Vector3d(coreWorldPos).sub(shipCenter).normalize();
Vector3d gravityForce = gravityDirection.mul(forceStrength);
// Apply the force to the ship using VS API
try {
// Use VS2's physics engine to apply force
Vector3d mcGravityForce = VectorConversionsMCKt.toMinecraft(gravityForce);
Vec3 mcShipCenter = VectorConversionsMCKt.toMinecraft(shipCenter);
ship.getPhysicsInertia().applyInvariantForce(mcGravityForce);
} catch (Exception e) {
// Force application failed, skip this ship
}
}
} catch (Exception e) {
// VS API not available, skip ship processing
})