fix world centre

This commit is contained in:
okx-code
2026-06-16 00:41:58 +01:00
parent 8bbe4b4a45
commit c0ca4e6457
4 changed files with 20 additions and 6 deletions

View File

@@ -5,6 +5,8 @@ transfer-failure-message: Unable to complete rocket transfer. Please reconnect a
source-world: world
world-radius: 10000
rocket-centre-x: 0
rocket-centre-z: 0
delta-v-meters-per-second: 10000
database:

View File

@@ -5,6 +5,8 @@ transfer-failure-message: Unable to complete rocket transfer. Please reconnect a
source-world: world
world-radius: 7000
rocket-centre-x: 0
rocket-centre-z: -20000
delta-v-meters-per-second: 6000
database:

View File

@@ -42,8 +42,6 @@ import vg.civcraft.mc.citadel.CitadelPermissionHandler;
public final class DestinationTransferListener implements Listener {
public static final int SPIRAL_ITERATION_DISTANCE = 8;
private static final int DESTINATION_CENTER_X = 0;
private static final int DESTINATION_CENTER_Z = -20_000;
private final ZorwethPlugin plugin;
private final Map<UUID, CompletableFuture<DestinationRocketTransfer>> futures = new ConcurrentHashMap<>();
@@ -225,8 +223,8 @@ public final class DestinationTransferListener implements Listener {
if (distanceSquared > radiusSquared) {
final double distance = Math.sqrt(distanceSquared);
final double scale = plugin.getWorldRadius() / distance;
rx = DESTINATION_CENTER_X + (int) ((rx - DESTINATION_CENTER_X) * scale);
rz = DESTINATION_CENTER_Z + (int) ((rz - DESTINATION_CENTER_Z) * scale);
rx = plugin.getRocketCentreX() + (int) ((rx - plugin.getRocketCentreX()) * scale);
rz = plugin.getRocketCentreZ() + (int) ((rz - plugin.getRocketCentreZ()) * scale);
}
final World world = Bukkit.getWorld(transfer.destinationWorld());
@@ -302,8 +300,8 @@ public final class DestinationTransferListener implements Listener {
}
private double getDistanceSquaredFromCenter(final int x, final int z) {
final double relativeX = x - DESTINATION_CENTER_X;
final double relativeZ = z - DESTINATION_CENTER_Z;
final double relativeX = x - plugin.getRocketCentreX();
final double relativeZ = z - plugin.getRocketCentreZ();
return relativeX * relativeX + relativeZ * relativeZ;
}

View File

@@ -47,6 +47,8 @@ public final class ZorwethPlugin extends JavaPlugin {
private String transferFailureMessage;
private long pioneerEndTimestampMillis;
private int worldRadius;
private int rocketCentreX;
private int rocketCentreZ;
private double deltaVMetersPerSecond;
private boolean researchEnabled;
private int researchPhaseOneRuns;
@@ -180,6 +182,14 @@ public final class ZorwethPlugin extends JavaPlugin {
return this.worldRadius;
}
public int getRocketCentreX() {
return rocketCentreX;
}
public int getRocketCentreZ() {
return rocketCentreZ;
}
public double getDeltaVMetersPerSecond() {
return this.deltaVMetersPerSecond;
}
@@ -193,6 +203,8 @@ public final class ZorwethPlugin extends JavaPlugin {
"Unable to complete rocket transfer. Please reconnect and try again.");
this.pioneerEndTimestampMillis = getConfig().getLong("pioneer-end-timestamp", 0L);
this.worldRadius = getConfig().getInt("world-radius", 0);
this.rocketCentreX = getConfig().getInt("world-centre-x", 0);
this.rocketCentreZ = getConfig().getInt("world-centre-z", 0);
this.deltaVMetersPerSecond = getConfig().getDouble("delta-v-meters-per-second", 10_000.0);
this.researchEnabled = getConfig().getBoolean("research.enabled", true);
this.researchPhaseOneRuns = loadPositiveInt("research.phase-one-runs", 1);