Fixed #77 planets not loading properly
This commit is contained in:
parent
427ee28ce4
commit
651d2d7549
2 changed files with 28 additions and 27 deletions
|
@ -340,27 +340,27 @@ public class EntityJump extends Entity {
|
||||||
moveX = moveY = moveZ = 0;
|
moveX = moveY = moveZ = 0;
|
||||||
|
|
||||||
if (toSpace) {
|
if (toSpace) {
|
||||||
Boolean planeFound = false;
|
Boolean planetFound = false;
|
||||||
Boolean planeValid = false;
|
Boolean planeValid = false;
|
||||||
int closestPlaneDistance = Integer.MAX_VALUE;
|
int closestPlanetDistance = Integer.MAX_VALUE;
|
||||||
Planet closestTransitionPlane = null;
|
Planet closestPlanet = null;
|
||||||
for (int iPlane = 0; (!planeValid) && iPlane < WarpDriveConfig.PLANETS.length; iPlane++) {
|
for (int iPlane = 0; (!planeValid) && iPlane < WarpDriveConfig.PLANETS.length; iPlane++) {
|
||||||
Planet transitionPlane = WarpDriveConfig.PLANETS[iPlane];
|
Planet planet = WarpDriveConfig.PLANETS[iPlane];
|
||||||
if (worldObj.provider.dimensionId == transitionPlane.dimensionId) {
|
if (worldObj.provider.dimensionId == planet.dimensionId) {
|
||||||
planeFound = true;
|
planetFound = true;
|
||||||
int planeDistance = transitionPlane.isValidToSpace(new VectorI(this));
|
int planetDistance = planet.isValidToSpace(new VectorI(this));
|
||||||
if (planeDistance == 0) {
|
if (planetDistance == 0) {
|
||||||
planeValid = true;
|
planeValid = true;
|
||||||
moveX = transitionPlane.spaceCenterX - transitionPlane.dimensionCenterX;
|
moveX = planet.spaceCenterX - planet.dimensionCenterX;
|
||||||
moveZ = transitionPlane.spaceCenterZ - transitionPlane.dimensionCenterZ;
|
moveZ = planet.spaceCenterZ - planet.dimensionCenterZ;
|
||||||
targetWorld = DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID);
|
targetWorld = DimensionManager.getWorld(WarpDriveConfig.G_SPACE_DIMENSION_ID);
|
||||||
} else if (closestPlaneDistance > planeDistance) {
|
} else if (closestPlanetDistance > planetDistance) {
|
||||||
closestPlaneDistance = planeDistance;
|
closestPlanetDistance = planetDistance;
|
||||||
closestTransitionPlane = transitionPlane;
|
closestPlanet = planet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!planeFound) {
|
if (!planetFound) {
|
||||||
LocalProfiler.stop();
|
LocalProfiler.stop();
|
||||||
String msg = "Unable to reach space!\nThere's no valid transition plane for current dimension " + worldObj.provider.getDimensionName() + " ("
|
String msg = "Unable to reach space!\nThere's no valid transition plane for current dimension " + worldObj.provider.getDimensionName() + " ("
|
||||||
+ worldObj.provider.dimensionId + ")";
|
+ worldObj.provider.dimensionId + ")";
|
||||||
|
@ -370,13 +370,13 @@ public class EntityJump extends Entity {
|
||||||
}
|
}
|
||||||
if (!planeValid) {
|
if (!planeValid) {
|
||||||
LocalProfiler.stop();
|
LocalProfiler.stop();
|
||||||
assert(closestTransitionPlane != null);
|
assert(closestPlanet != null);
|
||||||
@SuppressWarnings("null") // Eclipse derp, don't remove
|
@SuppressWarnings("null") // Eclipse derp, don't remove
|
||||||
String msg = "Ship is outside border, unable to reach space!\nClosest transition plane is ~" + closestPlaneDistance + " m away ("
|
String msg = "Ship is outside border, unable to reach space!\nClosest transition plane is ~" + closestPlanetDistance + " m away ("
|
||||||
+ (closestTransitionPlane.dimensionCenterX - closestTransitionPlane.borderSizeX) + ", 250,"
|
+ (closestPlanet.dimensionCenterX - closestPlanet.borderSizeX) + ", 250,"
|
||||||
+ (closestTransitionPlane.dimensionCenterZ - closestTransitionPlane.borderSizeZ) + ") to ("
|
+ (closestPlanet.dimensionCenterZ - closestPlanet.borderSizeZ) + ") to ("
|
||||||
+ (closestTransitionPlane.dimensionCenterX + closestTransitionPlane.borderSizeX) + ", 255,"
|
+ (closestPlanet.dimensionCenterX + closestPlanet.borderSizeX) + ", 255,"
|
||||||
+ (closestTransitionPlane.dimensionCenterZ + closestTransitionPlane.borderSizeZ) + ")";
|
+ (closestPlanet.dimensionCenterZ + closestPlanet.borderSizeZ) + ")";
|
||||||
messageToAllPlayersOnShip(msg);
|
messageToAllPlayersOnShip(msg);
|
||||||
killEntity(msg);
|
killEntity(msg);
|
||||||
return;
|
return;
|
||||||
|
@ -385,17 +385,17 @@ public class EntityJump extends Entity {
|
||||||
Boolean planeFound = false;
|
Boolean planeFound = false;
|
||||||
int closestPlaneDistance = Integer.MAX_VALUE;
|
int closestPlaneDistance = Integer.MAX_VALUE;
|
||||||
Planet closestTransitionPlane = null;
|
Planet closestTransitionPlane = null;
|
||||||
for (int iPlane = 0; (!planeFound) && iPlane < WarpDriveConfig.PLANETS.length; iPlane++) {
|
for (int iPlanet = 0; (!planeFound) && iPlanet < WarpDriveConfig.PLANETS.length; iPlanet++) {
|
||||||
Planet transitionPlane = WarpDriveConfig.PLANETS[iPlane];
|
Planet planet = WarpDriveConfig.PLANETS[iPlanet];
|
||||||
int planeDistance = transitionPlane.isValidFromSpace(new VectorI(this));
|
int planeDistance = planet.isValidFromSpace(new VectorI(this));
|
||||||
if (planeDistance == 0) {
|
if (planeDistance == 0) {
|
||||||
planeFound = true;
|
planeFound = true;
|
||||||
moveX = transitionPlane.dimensionCenterX - transitionPlane.spaceCenterX;
|
moveX = planet.dimensionCenterX - planet.spaceCenterX;
|
||||||
moveZ = transitionPlane.dimensionCenterZ - transitionPlane.spaceCenterZ;
|
moveZ = planet.dimensionCenterZ - planet.spaceCenterZ;
|
||||||
targetWorld = DimensionManager.getWorld(transitionPlane.dimensionId);
|
targetWorld = DimensionManager.getWorld(planet.dimensionId);
|
||||||
} else if (closestPlaneDistance > planeDistance) {
|
} else if (closestPlaneDistance > planeDistance) {
|
||||||
closestPlaneDistance = planeDistance;
|
closestPlaneDistance = planeDistance;
|
||||||
closestTransitionPlane = transitionPlane;
|
closestTransitionPlane = planet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!planeFound) {
|
if (!planeFound) {
|
||||||
|
|
|
@ -389,6 +389,7 @@ public class WarpDriveConfig {
|
||||||
Planet planet = new Planet(planetInts[0], planetInts[1], planetInts[2], planetInts[3], planetInts[4], planetInts[5], planetInts[6]);
|
Planet planet = new Planet(planetInts[0], planetInts[1], planetInts[2], planetInts[3], planetInts[4], planetInts[5], planetInts[6]);
|
||||||
WarpDrive.logger.info("Adding '" + name + "' as " + planet.toString());
|
WarpDrive.logger.info("Adding '" + name + "' as " + planet.toString());
|
||||||
PLANETS[index] = planet;
|
PLANETS[index] = planet;
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
// FIXME: check planets aren't overlapping
|
// FIXME: check planets aren't overlapping
|
||||||
// We're not checking invalid dimension id, so they can be pre-allocated (see MystCraft)
|
// We're not checking invalid dimension id, so they can be pre-allocated (see MystCraft)
|
||||||
|
|
Loading…
Add table
Reference in a new issue