Fixed hyperspace transitions
This commit is contained in:
parent
98deb8e55f
commit
8daa2d20f4
6 changed files with 237 additions and 116 deletions
|
@ -22,7 +22,7 @@ public class CommandReload extends CommandBase {
|
|||
if (sender == null) { return; }
|
||||
|
||||
WarpDriveConfig.reload();
|
||||
Commons.addChatMessage(sender, "WarpDrive configuration has been reloaded. Use at your own risk!");
|
||||
Commons.addChatMessage(sender, "§aWarpDrive configuration has been reloaded.\n§aUse at your own risk!");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,7 +35,7 @@ public class CommandSpace extends CommandBase {
|
|||
MinecraftServer server = MinecraftServer.getServer();
|
||||
|
||||
// set defaults
|
||||
int targetDimensionId = Integer.MAX_VALUE;
|
||||
int dimensionIdTarget = Integer.MAX_VALUE;
|
||||
|
||||
EntityPlayerMP[] entityPlayerMPs = null;
|
||||
if (commandSender instanceof EntityPlayerMP) {
|
||||
|
@ -56,7 +56,7 @@ public class CommandSpace extends CommandBase {
|
|||
if (entityPlayerMPs_found != null) {
|
||||
entityPlayerMPs = entityPlayerMPs_found;
|
||||
} else if (commandSender instanceof EntityPlayer) {
|
||||
targetDimensionId = StarMapRegistry.getDimensionId(params[0], (EntityPlayer) commandSender);
|
||||
dimensionIdTarget = StarMapRegistry.getDimensionId(params[0], (EntityPlayer) commandSender);
|
||||
} else {
|
||||
Commons.addChatMessage(commandSender, "§c/space: player not found '" + params[0] + "'");
|
||||
return;
|
||||
|
@ -70,7 +70,7 @@ public class CommandSpace extends CommandBase {
|
|||
Commons.addChatMessage(commandSender, "§c/space: player not found '" + params[0] + "'");
|
||||
return;
|
||||
}
|
||||
targetDimensionId = StarMapRegistry.getDimensionId(params[1], entityPlayerMPs[0]);
|
||||
dimensionIdTarget = StarMapRegistry.getDimensionId(params[1], entityPlayerMPs[0]);
|
||||
|
||||
} else {
|
||||
Commons.addChatMessage(commandSender, "§c/space: too many arguments " + params.length);
|
||||
|
@ -85,14 +85,14 @@ public class CommandSpace extends CommandBase {
|
|||
|
||||
for (EntityPlayerMP entityPlayerMP : entityPlayerMPs) {
|
||||
// toggle between overworld and space if no dimension was provided
|
||||
int newX = MathHelper.floor_double(entityPlayerMP.posX);
|
||||
int newY = Math.min(255, Math.max(0, MathHelper.floor_double(entityPlayerMP.posY)));
|
||||
int newZ = MathHelper.floor_double(entityPlayerMP.posZ);
|
||||
int xTarget = MathHelper.floor_double(entityPlayerMP.posX);
|
||||
int yTarget = Math.min(255, Math.max(0, MathHelper.floor_double(entityPlayerMP.posY)));
|
||||
int zTarget = MathHelper.floor_double(entityPlayerMP.posZ);
|
||||
final CelestialObject celestialObjectCurrent = StarMapRegistry.getCelestialObject(entityPlayerMP.worldObj.provider.dimensionId, (int) entityPlayerMP.posX, (int) entityPlayerMP.posZ);
|
||||
if (targetDimensionId == Integer.MAX_VALUE) {
|
||||
if (dimensionIdTarget == Integer.MAX_VALUE) {
|
||||
if (celestialObjectCurrent == null) {
|
||||
Commons.addChatMessage(commandSender,
|
||||
String.format("§c/space: player %s is in unknown dimension %d. Try specifying an explicit target dimension instead.",
|
||||
String.format("§c/space: player %s is in unknown dimension %d.\n§cTry specifying an explicit target dimension instead.",
|
||||
entityPlayerMP.getCommandSenderName(), entityPlayerMP.worldObj.provider.dimensionId));
|
||||
continue;
|
||||
}
|
||||
|
@ -100,92 +100,93 @@ public class CommandSpace extends CommandBase {
|
|||
// in space or hyperspace => move to closest child
|
||||
final CelestialObject celestialObjectChild = StarMapRegistry.getClosestChildCelestialObject(entityPlayerMP.worldObj.provider.dimensionId, (int) entityPlayerMP.posX, (int) entityPlayerMP.posZ);
|
||||
if (celestialObjectChild == null) {
|
||||
targetDimensionId = 0;
|
||||
dimensionIdTarget = 0;
|
||||
} else if (celestialObjectChild.isVirtual) {
|
||||
Commons.addChatMessage(commandSender,
|
||||
String.format("§c/space: player %s can't go to %s.\nThis is a virtual celestial object. Try specifying an explicit target dimension instead.",
|
||||
String.format("§c/space: player %s can't go to %s.\n§cThis is a virtual celestial object. Try specifying an explicit target dimension instead.",
|
||||
entityPlayerMP.getCommandSenderName(), celestialObjectChild.getFullName()));
|
||||
continue;
|
||||
} else {
|
||||
targetDimensionId = celestialObjectChild.dimensionId;
|
||||
dimensionIdTarget = celestialObjectChild.dimensionId;
|
||||
final VectorI vEntry = celestialObjectChild.getEntryOffset();
|
||||
newX += vEntry.x;
|
||||
newY += vEntry.y;
|
||||
newZ += vEntry.z;
|
||||
xTarget += vEntry.x;
|
||||
yTarget += vEntry.y;
|
||||
zTarget += vEntry.z;
|
||||
}
|
||||
} else {
|
||||
// on a planet => move to space
|
||||
final CelestialObject celestialObjectParent = StarMapRegistry.getParentCelestialObject(celestialObjectCurrent);
|
||||
if (celestialObjectParent == null) {
|
||||
targetDimensionId = 0;
|
||||
dimensionIdTarget = 0;
|
||||
|
||||
} else {
|
||||
targetDimensionId = celestialObjectParent.dimensionId;
|
||||
dimensionIdTarget = celestialObjectParent.dimensionId;
|
||||
final VectorI vEntry = celestialObjectCurrent.getEntryOffset();
|
||||
newX -= vEntry.x;
|
||||
newY -= vEntry.y;
|
||||
newZ -= vEntry.z;
|
||||
xTarget -= vEntry.x;
|
||||
yTarget -= vEntry.y;
|
||||
zTarget -= vEntry.z;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// adjust offset when it's directly above or below us
|
||||
if (celestialObjectCurrent.parentDimensionId == targetDimensionId) {// moving to parent explicitly
|
||||
if ( celestialObjectCurrent != null
|
||||
&& celestialObjectCurrent.parentDimensionId == dimensionIdTarget ) {// moving to parent explicitly
|
||||
final VectorI vEntry = celestialObjectCurrent.getEntryOffset();
|
||||
newX -= vEntry.x;
|
||||
newY -= vEntry.y;
|
||||
newZ -= vEntry.z;
|
||||
xTarget -= vEntry.x;
|
||||
yTarget -= vEntry.y;
|
||||
zTarget -= vEntry.z;
|
||||
} else {
|
||||
final CelestialObject celestialObjectChild = StarMapRegistry.getClosestChildCelestialObject(entityPlayerMP.worldObj.provider.dimensionId, (int) entityPlayerMP.posX, (int) entityPlayerMP.posZ);
|
||||
if (celestialObjectChild != null && celestialObjectChild.dimensionId == targetDimensionId) {// moving to child explicitly
|
||||
if (celestialObjectChild != null && celestialObjectChild.dimensionId == dimensionIdTarget) {// moving to child explicitly
|
||||
final VectorI vEntry = celestialObjectChild.getEntryOffset();
|
||||
newX += vEntry.x;
|
||||
newY += vEntry.y;
|
||||
newZ += vEntry.z;
|
||||
xTarget += vEntry.x;
|
||||
yTarget += vEntry.y;
|
||||
zTarget += vEntry.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get target celestial object
|
||||
final CelestialObject celestialObject = StarMapRegistry.getCelestialObject(targetDimensionId, newX, newZ);
|
||||
final CelestialObject celestialObjectTarget = StarMapRegistry.getCelestialObject(dimensionIdTarget, xTarget, zTarget);
|
||||
|
||||
// force to center if we're outside the border
|
||||
if ( celestialObject != null
|
||||
&& celestialObject.getSquareDistanceOutsideBorder(targetDimensionId, newX, newZ) > 0 ) {
|
||||
if ( celestialObjectTarget != null
|
||||
&& celestialObjectTarget.isInsideBorder(xTarget, zTarget) ) {
|
||||
// outside
|
||||
newX = celestialObject.dimensionCenterX;
|
||||
newZ = celestialObject.dimensionCenterZ;
|
||||
xTarget = celestialObjectTarget.dimensionCenterX;
|
||||
zTarget = celestialObjectTarget.dimensionCenterZ;
|
||||
}
|
||||
|
||||
// get target world
|
||||
WorldServer targetWorld = server.worldServerForDimension(targetDimensionId);
|
||||
if (targetWorld == null) {
|
||||
Commons.addChatMessage(commandSender, "§c/space: undefined dimension '" + targetDimensionId + "'");
|
||||
WorldServer worldTarget = server.worldServerForDimension(dimensionIdTarget);
|
||||
if (worldTarget == null) {
|
||||
Commons.addChatMessage(commandSender, "§c/space: undefined dimension '" + dimensionIdTarget + "'");
|
||||
continue;
|
||||
}
|
||||
|
||||
// inform player
|
||||
String message = "Teleporting player " + entityPlayerMP.getCommandSenderName() + " to dimension " + targetDimensionId + "..."; // + ":" + targetWorld.getWorldInfo().getWorldName();
|
||||
String message = "§aTeleporting player " + entityPlayerMP.getCommandSenderName() + " to dimension " + dimensionIdTarget + "..."; // + ":" + worldTarget.getWorldInfo().getWorldName();
|
||||
Commons.addChatMessage(commandSender, message);
|
||||
WarpDrive.logger.info(message);
|
||||
if (commandSender != entityPlayerMP) {
|
||||
Commons.addChatMessage(entityPlayerMP, commandSender.getCommandSenderName() + " is teleporting you to dimension " + targetDimensionId); // + ":" + targetWorld.getWorldInfo().getWorldName());
|
||||
Commons.addChatMessage(entityPlayerMP, commandSender.getCommandSenderName() + " is teleporting you to dimension " + dimensionIdTarget); // + ":" + worldTarget.getWorldInfo().getWorldName());
|
||||
}
|
||||
|
||||
// find a good spot
|
||||
|
||||
if ( (targetWorld.isAirBlock(newX, newY - 1, newZ) && !entityPlayerMP.capabilities.allowFlying)
|
||||
|| !targetWorld.isAirBlock(newX, newY, newZ)
|
||||
|| !targetWorld.isAirBlock(newX, newY + 1, newZ) ) {// non solid ground and can't fly, or inside blocks
|
||||
newY = targetWorld.getTopSolidOrLiquidBlock(newX, newZ) + 1;
|
||||
if (newY == 0) {
|
||||
newY = 128;
|
||||
if ( (worldTarget.isAirBlock(xTarget, yTarget - 1, zTarget) && !entityPlayerMP.capabilities.allowFlying)
|
||||
|| !worldTarget.isAirBlock(xTarget, yTarget, zTarget)
|
||||
|| !worldTarget.isAirBlock(xTarget, yTarget + 1, zTarget) ) {// non solid ground and can't fly, or inside blocks
|
||||
yTarget = worldTarget.getTopSolidOrLiquidBlock(xTarget, zTarget) + 1;
|
||||
if (yTarget == 0) {
|
||||
yTarget = 128;
|
||||
} else {
|
||||
for (int safeY = newY - 3; safeY > Math.max(1, newY - 20); safeY--) {
|
||||
if (!targetWorld.isAirBlock(newX, safeY - 1, newZ)
|
||||
&& targetWorld.isAirBlock(newX, safeY , newZ)
|
||||
&& targetWorld.isAirBlock(newX, safeY + 1, newZ)) {
|
||||
newY = safeY;
|
||||
for (int safeY = yTarget - 3; safeY > Math.max(1, yTarget - 20); safeY--) {
|
||||
if (!worldTarget.isAirBlock(xTarget, safeY - 1, zTarget)
|
||||
&& worldTarget.isAirBlock(xTarget, safeY , zTarget)
|
||||
&& worldTarget.isAirBlock(xTarget, safeY + 1, zTarget)) {
|
||||
yTarget = safeY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -193,9 +194,9 @@ public class CommandSpace extends CommandBase {
|
|||
}
|
||||
|
||||
// actual teleportation
|
||||
final SpaceTeleporter teleporter = new SpaceTeleporter(targetWorld, 0, newX, newY, newZ);
|
||||
server.getConfigurationManager().transferPlayerToDimension(entityPlayerMP, targetDimensionId, teleporter);
|
||||
entityPlayerMP.setPositionAndUpdate(newX + 0.5D, newY + 0.2D, newZ + 0.5D);
|
||||
final SpaceTeleporter teleporter = new SpaceTeleporter(worldTarget, 0, xTarget, yTarget, zTarget);
|
||||
server.getConfigurationManager().transferPlayerToDimension(entityPlayerMP, dimensionIdTarget, teleporter);
|
||||
entityPlayerMP.setPositionAndUpdate(xTarget + 0.5D, yTarget + 0.2D, zTarget + 0.5D);
|
||||
entityPlayerMP.sendPlayerAbilities();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,12 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
/**
|
||||
* An astronomical object or celestial object is a naturally occurring physical entity, association, or structure in the observable universe.
|
||||
* They can be a planet, a more abstract construct like solar system (space dimension) or the all mighty hyperspace.
|
||||
|
@ -34,20 +37,21 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
|
||||
public String group;
|
||||
public String name;
|
||||
public boolean isVirtual;
|
||||
public int dimensionId;
|
||||
public int dimensionCenterX, dimensionCenterZ;
|
||||
public int borderRadiusX, borderRadiusZ;
|
||||
|
||||
public String parentGroup;
|
||||
public String parentName;
|
||||
public int parentDimensionId;
|
||||
public int parentCenterX, parentCenterZ;
|
||||
|
||||
public boolean isProvidedByWarpDrive;
|
||||
private boolean isProvidedByWarpDrive_defined = false;
|
||||
public int borderRadiusX, borderRadiusZ;
|
||||
|
||||
public boolean isVirtual;
|
||||
public int dimensionId;
|
||||
public int dimensionCenterX, dimensionCenterZ;
|
||||
public double gravity;
|
||||
public boolean isBreathable;
|
||||
public boolean isProvidedByWarpDrive;
|
||||
private boolean isProvidedByWarpDrive_defined = false;
|
||||
|
||||
private final RandomCollection<StructureGroup> randomStructures = new RandomCollection<>();
|
||||
|
||||
|
@ -156,9 +160,9 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
if (listDimensions.size() == 0) {
|
||||
isVirtual = true;
|
||||
dimensionId = 0;
|
||||
isProvidedByWarpDrive = false;
|
||||
isBreathable = true;
|
||||
gravity = GRAVITY_NORMAL;
|
||||
isBreathable = true;
|
||||
isProvidedByWarpDrive = false;
|
||||
dimensionCenterX = 0;
|
||||
dimensionCenterZ = 0;
|
||||
} else {
|
||||
|
@ -166,8 +170,8 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
|
||||
final Element elementDimension = listDimensions.get(0);
|
||||
dimensionId = Integer.parseInt(elementDimension.getAttribute("id"));
|
||||
isBreathable = Boolean.parseBoolean(elementDimension.getAttribute("isBreathable"));
|
||||
gravity = parseGravity(elementDimension.getAttribute("gravity"));
|
||||
isBreathable = Boolean.parseBoolean(elementDimension.getAttribute("isBreathable"));
|
||||
if (elementDimension.hasAttribute("isProvidedByWarpDrive")) {
|
||||
isProvidedByWarpDrive = Boolean.parseBoolean(elementDimension.getAttribute("isProvidedByWarpDrive"));
|
||||
isProvidedByWarpDrive_defined = true;
|
||||
|
@ -335,8 +339,8 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
|
||||
public AxisAlignedBB getWorldBorderArea() {
|
||||
return AxisAlignedBB.getBoundingBox(
|
||||
(dimensionCenterX - borderRadiusX), 0, (dimensionCenterZ - borderRadiusZ),
|
||||
(dimensionCenterX + borderRadiusX), 255, (dimensionCenterZ + borderRadiusZ) );
|
||||
(dimensionCenterX - borderRadiusX), 0, (dimensionCenterZ - borderRadiusZ),
|
||||
(dimensionCenterX + borderRadiusX), 255, (dimensionCenterZ + borderRadiusZ) );
|
||||
}
|
||||
|
||||
public AxisAlignedBB getAreaToReachParent() {
|
||||
|
@ -373,40 +377,41 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Compute distance from border to further point in an area.
|
||||
* Verify that the given area is fully contained within the border.
|
||||
* It's up to caller to verify if this celestial object is matched.
|
||||
*
|
||||
* @param aabb bounding box that should fit within border
|
||||
* @return distance to transition borders, 0 if take off is possible
|
||||
* @return true if we're fully inside the border
|
||||
*/
|
||||
public double getSquareDistanceOutsideBorder(final int dimensionId, final AxisAlignedBB aabb) {
|
||||
if (dimensionId != this.dimensionId) {
|
||||
return Double.POSITIVE_INFINITY;
|
||||
}
|
||||
public boolean isInsideBorder(final AxisAlignedBB aabb) {
|
||||
final double rangeX = Math.max(Math.abs(aabb.minX - dimensionCenterX), Math.abs(aabb.maxX - dimensionCenterX));
|
||||
final double rangeZ = Math.max(Math.abs(aabb.minZ - dimensionCenterZ), Math.abs(aabb.maxZ - dimensionCenterZ));
|
||||
final double dX = rangeX - borderRadiusX;
|
||||
final double dZ = rangeZ - borderRadiusZ;
|
||||
if ((rangeX <= borderRadiusX) && (rangeZ <= borderRadiusZ)) {
|
||||
return - (dX * dX + dZ * dZ);
|
||||
}
|
||||
return (dX * dX + dZ * dZ);
|
||||
return (rangeX <= borderRadiusX) && (rangeZ <= borderRadiusZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify that the given position is within the border.
|
||||
* It's up to caller to verify if this celestial object is matched.
|
||||
*
|
||||
* @param x coordinates inside the celestial object
|
||||
* @param z coordinates inside the celestial object
|
||||
* @return true if we're fully inside the border
|
||||
*/
|
||||
public boolean isInsideBorder(final double x, final double z) {
|
||||
final double rangeX = Math.abs(x - dimensionCenterX);
|
||||
final double rangeZ = Math.abs(z - dimensionCenterZ);
|
||||
return (rangeX <= borderRadiusX) && (rangeZ <= borderRadiusZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute distance to reach closest border, while inside the same dimension.
|
||||
*
|
||||
* @param dimensionId dimension id
|
||||
* @param x coordinates inside the celestial object
|
||||
* @param z coordinates inside the celestial object
|
||||
* @return 'square' distance to the closest border,
|
||||
* <=0 if we're inside, > 0 if we're outside,
|
||||
* +INF if we're in the wrong dimension
|
||||
* <=0 if we're inside, > 0 if we're outside
|
||||
*/
|
||||
public double getSquareDistanceOutsideBorder(final int dimensionId, final double x, final double z) {
|
||||
if (dimensionId != this.dimensionId) {
|
||||
return Double.POSITIVE_INFINITY;
|
||||
}
|
||||
public double getSquareDistanceOutsideBorder(final double x, final double z) {
|
||||
final double rangeX = Math.abs(x - dimensionCenterX);
|
||||
final double rangeZ = Math.abs(z - dimensionCenterZ);
|
||||
final double dX = rangeX - borderRadiusX;
|
||||
|
@ -450,34 +455,96 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
return dx * dx + dz * dz;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
dimensionId = tag.getInteger("dimensionId");
|
||||
dimensionCenterX = tag.getInteger("dimensionCenterX");
|
||||
dimensionCenterZ = tag.getInteger("dimensionCenterZ");
|
||||
borderRadiusX = tag.getInteger("borderSizeX");
|
||||
borderRadiusZ = tag.getInteger("borderSizeZ");
|
||||
parentDimensionId = tag.getInteger("parentDimensionId");
|
||||
parentCenterX = tag.getInteger("parentCenterX");
|
||||
parentCenterZ = tag.getInteger("parentCenterZ");
|
||||
isProvidedByWarpDrive = tag.getBoolean("isProvidedByWarpDrive");
|
||||
gravity = tag.getDouble("gravity");
|
||||
isBreathable = tag.getBoolean("isBreathable");
|
||||
// @TODO: mapGenerationRatios
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
group = nbtTagCompound.getString("group");
|
||||
name = nbtTagCompound.getString("name");
|
||||
|
||||
parentGroup = nbtTagCompound.getString("parentGroup");
|
||||
parentName = nbtTagCompound.getString("parentName");
|
||||
parentCenterX = nbtTagCompound.getInteger("parentCenterX");
|
||||
parentCenterZ = nbtTagCompound.getInteger("parentCenterZ");
|
||||
|
||||
borderRadiusX = nbtTagCompound.getInteger("borderRadiusX");
|
||||
borderRadiusZ = nbtTagCompound.getInteger("borderRadiusZ");
|
||||
|
||||
isVirtual = nbtTagCompound.getBoolean("isVirtual");
|
||||
if (isVirtual) {
|
||||
dimensionId = 0;
|
||||
dimensionCenterX = 0;
|
||||
dimensionCenterZ = 0;
|
||||
gravity = GRAVITY_NORMAL;
|
||||
isBreathable = true;
|
||||
isProvidedByWarpDrive = false;
|
||||
} else {
|
||||
dimensionId = nbtTagCompound.getInteger("dimensionId");
|
||||
dimensionCenterX = nbtTagCompound.getInteger("dimensionCenterX");
|
||||
dimensionCenterZ = nbtTagCompound.getInteger("dimensionCenterZ");
|
||||
gravity = nbtTagCompound.getDouble("gravity");
|
||||
isBreathable = nbtTagCompound.getBoolean("isBreathable");
|
||||
isProvidedByWarpDrive = nbtTagCompound.getBoolean("isProvidedByWarpDrive");
|
||||
}
|
||||
|
||||
// randomStructures are server side only
|
||||
|
||||
backgroundColor = new ColorData(nbtTagCompound.getCompoundTag("backgroundColor"));
|
||||
baseStarBrightness = nbtTagCompound.getFloat("baseStarBrightness");
|
||||
vanillaStarBrightness = nbtTagCompound.getFloat("vanillaStarBrightness");
|
||||
opacityCelestialObjects = nbtTagCompound.getFloat("opacityCelestialObjects");
|
||||
colorFog = new ColorData(nbtTagCompound.getCompoundTag("colorFog"));
|
||||
factorFog = new ColorData(nbtTagCompound.getCompoundTag("factorFog"));
|
||||
|
||||
final NBTTagList nbtTagListRenderData = nbtTagCompound.getTagList("renderData", NBT.TAG_COMPOUND);
|
||||
final int countRender = nbtTagListRenderData.tagCount();
|
||||
setRenderData = new LinkedHashSet<>(countRender);
|
||||
for(int indexRenderData = 0; indexRenderData < countRender; indexRenderData++) {
|
||||
final NBTTagCompound tagCompoundRenderData = nbtTagListRenderData.getCompoundTagAt(indexRenderData);
|
||||
setRenderData.add(new RenderData(tagCompoundRenderData));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
tag.setInteger("dimensionId", dimensionId);
|
||||
tag.setInteger("dimensionCenterX", dimensionCenterX);
|
||||
tag.setInteger("dimensionCenterZ", dimensionCenterZ);
|
||||
tag.setInteger("borderRadiusX", borderRadiusX);
|
||||
tag.setInteger("borderRadiusZ", borderRadiusZ);
|
||||
tag.setInteger("parentDimensionId", parentDimensionId);
|
||||
tag.setInteger("parentCenterX", parentCenterX);
|
||||
tag.setInteger("parentCenterZ", parentCenterZ);
|
||||
tag.setBoolean("isProvidedByWarpDrive", isProvidedByWarpDrive);
|
||||
tag.setDouble("gravity", gravity);
|
||||
tag.setBoolean("isBreathable", isBreathable);
|
||||
// @TODO: mapGenerationRatios
|
||||
public void writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
nbtTagCompound.setString("group", group);
|
||||
nbtTagCompound.setString("name", name);
|
||||
|
||||
nbtTagCompound.setString("parentGroup", parentGroup);
|
||||
nbtTagCompound.setString("parentName", parentName);
|
||||
nbtTagCompound.setInteger("parentCenterX", parentCenterX);
|
||||
nbtTagCompound.setInteger("parentCenterZ", parentCenterZ);
|
||||
|
||||
nbtTagCompound.setInteger("borderRadiusX", borderRadiusX);
|
||||
nbtTagCompound.setInteger("borderRadiusZ", borderRadiusZ);
|
||||
|
||||
nbtTagCompound.setBoolean("isVirtual", isVirtual);
|
||||
if (isVirtual) {
|
||||
dimensionId = 0;
|
||||
dimensionCenterX = 0;
|
||||
dimensionCenterZ = 0;
|
||||
gravity = GRAVITY_NORMAL;
|
||||
isBreathable = true;
|
||||
isProvidedByWarpDrive = false;
|
||||
} else {
|
||||
nbtTagCompound.setInteger("dimensionId", dimensionId);
|
||||
nbtTagCompound.setInteger("dimensionCenterX", dimensionCenterX);
|
||||
nbtTagCompound.setInteger("dimensionCenterZ", dimensionCenterZ);
|
||||
nbtTagCompound.setDouble("gravity", gravity);
|
||||
nbtTagCompound.setBoolean("isBreathable", isBreathable);
|
||||
nbtTagCompound.setBoolean("isProvidedByWarpDrive", isProvidedByWarpDrive);
|
||||
}
|
||||
|
||||
// randomStructures are server side only
|
||||
|
||||
nbtTagCompound.setTag("backgroundColor", backgroundColor.writeToNBT(new NBTTagCompound()));
|
||||
nbtTagCompound.setFloat("baseStarBrightness", baseStarBrightness);
|
||||
nbtTagCompound.setFloat("vanillaStarBrightness", vanillaStarBrightness);
|
||||
nbtTagCompound.setFloat("opacityCelestialObjects", opacityCelestialObjects);
|
||||
nbtTagCompound.setTag("colorFog", colorFog.writeToNBT(new NBTTagCompound()));
|
||||
nbtTagCompound.setTag("factorFog", factorFog.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
final NBTTagList nbtTagListRenderData = new NBTTagList();
|
||||
for(final RenderData renderData : setRenderData) {
|
||||
nbtTagListRenderData.appendTag(renderData.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
nbtTagCompound.setTag("renderData", nbtTagListRenderData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -518,7 +585,7 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
public float green;
|
||||
public float blue;
|
||||
|
||||
ColorData(final float red, final float green, final float blue) throws InvalidXmlException {
|
||||
ColorData(final float red, final float green, final float blue) {
|
||||
this.red = red;
|
||||
this.green = green;
|
||||
this.blue = blue;
|
||||
|
@ -537,6 +604,23 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
blue = 0.5F;
|
||||
}
|
||||
}
|
||||
|
||||
ColorData(final NBTTagCompound nbtTagCompound) {
|
||||
readFromNBT(nbtTagCompound);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
red = nbtTagCompound.getFloat("red");
|
||||
green = nbtTagCompound.getFloat("green");
|
||||
blue = nbtTagCompound.getFloat("blue");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
nbtTagCompound.setFloat("red", red);
|
||||
nbtTagCompound.setFloat("green", green);
|
||||
nbtTagCompound.setFloat("blue", blue);
|
||||
return nbtTagCompound;
|
||||
}
|
||||
}
|
||||
|
||||
public class RenderData {
|
||||
|
@ -598,5 +682,42 @@ public class CelestialObject implements Cloneable, IStringSerializable {
|
|||
isAdditive = Boolean.parseBoolean(elementRender.getAttribute("additive"));
|
||||
}
|
||||
}
|
||||
|
||||
RenderData(final NBTTagCompound nbtTagCompound) {
|
||||
readFromNBT(nbtTagCompound);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound) {
|
||||
red = nbtTagCompound.getFloat("red");
|
||||
green = nbtTagCompound.getFloat("green");
|
||||
blue = nbtTagCompound.getFloat("blue");
|
||||
alpha = nbtTagCompound.getFloat("alpha");
|
||||
texture = nbtTagCompound.getString("texture");
|
||||
if (texture == null || texture.isEmpty()) {
|
||||
texture = null;
|
||||
resourceLocation = null;
|
||||
periodU = 1.0D;
|
||||
periodV = 1.0D;
|
||||
isAdditive = false;
|
||||
} else {
|
||||
resourceLocation = new ResourceLocation(texture);
|
||||
periodU = nbtTagCompound.getDouble("periodU");
|
||||
periodV = nbtTagCompound.getDouble("periodV");
|
||||
isAdditive = nbtTagCompound.getBoolean("isAdditive");
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) {
|
||||
nbtTagCompound.setFloat("red", red);
|
||||
nbtTagCompound.setFloat("green", green);
|
||||
nbtTagCompound.setFloat("blue", blue);
|
||||
nbtTagCompound.setFloat("alpha", alpha);
|
||||
if (texture != null) {
|
||||
nbtTagCompound.setDouble("periodU", periodU);
|
||||
nbtTagCompound.setDouble("periodV", periodV);
|
||||
nbtTagCompound.setBoolean("isAdditive", isAdditive);
|
||||
}
|
||||
return nbtTagCompound;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -125,7 +125,7 @@ public class StarMapRegistry {
|
|||
CelestialObject celestialObjectClosest = null;
|
||||
for (final CelestialObject celestialObject : CelestialObjectManager.celestialObjects) {
|
||||
if (dimensionId == celestialObject.dimensionId) {
|
||||
final double distanceSquared = celestialObject.getSquareDistanceOutsideBorder(dimensionId, x, z);
|
||||
final double distanceSquared = celestialObject.getSquareDistanceOutsideBorder(x, z);
|
||||
if (distanceSquared <= 0) {
|
||||
return celestialObject;
|
||||
} else if (distanceClosest > distanceSquared) {
|
||||
|
|
|
@ -618,10 +618,9 @@ public class JumpSequencer extends AbstractSequencer {
|
|||
|
||||
} else {
|
||||
// are we in range?
|
||||
final double distanceSquared = celestialObjectTarget.getSquareDistanceOutsideBorder(targetWorld.provider.dimensionId, aabbTarget);
|
||||
if (distanceSquared > 0) {
|
||||
AxisAlignedBB axisAlignedBB = celestialObjectTarget.getWorldBorderArea();
|
||||
String message = String.format(
|
||||
if (!celestialObjectTarget.isInsideBorder(aabbTarget)) {
|
||||
final AxisAlignedBB axisAlignedBB = celestialObjectTarget.getWorldBorderArea();
|
||||
final String message = String.format(
|
||||
"Target ship position is outside planet border, unable to jump!\n"
|
||||
+ "World borders are (%d %d %d) to (%d %d %d).",
|
||||
(int) axisAlignedBB.minX, (int) axisAlignedBB.minY, (int) axisAlignedBB.minZ,
|
||||
|
@ -783,7 +782,7 @@ public class JumpSequencer extends AbstractSequencer {
|
|||
}
|
||||
|
||||
// are we clear for transit?
|
||||
final double distanceSquared = celestialObjectSource.getSquareDistanceOutsideBorder(sourceWorld.provider.dimensionId, ship.coreX, ship.coreZ);
|
||||
final double distanceSquared = celestialObjectSource.getSquareDistanceOutsideBorder(ship.coreX, ship.coreZ);
|
||||
if (distanceSquared > 0) {
|
||||
final AxisAlignedBB axisAlignedBB = celestialObjectSource.getAreaToReachParent();
|
||||
reason.append(String.format(
|
||||
|
|
|
@ -59,7 +59,7 @@ public class LivingHandler {
|
|||
// unregistered dimension => exit
|
||||
return;
|
||||
}
|
||||
final double distanceSquared = celestialObject.getSquareDistanceOutsideBorder(entity.worldObj.provider.dimensionId, x, z);
|
||||
final double distanceSquared = celestialObject.getSquareDistanceOutsideBorder(x, z);
|
||||
if (distanceSquared <= 0.0D) {
|
||||
// are we close to the border?
|
||||
if ( Math.abs(distanceSquared) <= BORDER_WARNING_RANGE_BLOCKS_SQUARED
|
||||
|
|
Loading…
Reference in a new issue