Progress on the New Save Format and Minor Fixes #88
@@ -75,7 +75,7 @@ public class DDTeleporter
|
|||||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
|
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
player.setPositionAndUpdate(x, y - 1, z);
|
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,8 @@ public class DDTeleporter
|
|||||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DDTeleporter.setEntityPosition(entity, x, y, z);
|
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 0.5);
|
||||||
|
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,7 +130,7 @@ public class DDTeleporter
|
|||||||
setEntityPosition(entity, x + 0.5, y, z + 1.5);
|
setEntityPosition(entity, x + 0.5, y, z + 1.5);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
setEntityPosition(entity, x, y, z);
|
setEntityPosition(entity, x + 0.5, y, z + 0.5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -455,10 +456,10 @@ public class DDTeleporter
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY(), source.getZ());
|
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
|
||||||
if (destination != null)
|
if (destination != null)
|
||||||
{
|
{
|
||||||
current.root().setDestination(link, source.getX(), source.getY(), source.getZ());
|
current.root().setDestination(link, destination.getX(), destination.getY(), destination.getZ());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,10 +218,12 @@ public class yCoordHelper
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Point3D findDropPoint(World world, int x, int y, int z)
|
public static Point3D findDropPoint(World world, int x, int startY, int z)
|
||||||
{
|
{
|
||||||
/*// Find a simple 2-block-high air gap
|
// Find a simple 2-block-high air gap
|
||||||
// Search across a 3x3 column
|
// Search across a 3x3 column
|
||||||
|
final int GAP_HEIGHT = 2;
|
||||||
|
|
||||||
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
|
int localX = x < 0 ? (x % 16) + 16 : (x % 16);
|
||||||
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
|
int localZ = z < 0 ? (z % 16) + 16 : (z % 16);
|
||||||
int cornerX = x - localX;
|
int cornerX = x - localX;
|
||||||
@@ -231,56 +233,45 @@ public class yCoordHelper
|
|||||||
|
|
||||||
Chunk chunk = initializeChunkArea(world, x >> 4, z >> 4);
|
Chunk chunk = initializeChunkArea(world, x >> 4, z >> 4);
|
||||||
|
|
||||||
|
int y, dx, dz, index;
|
||||||
int height = world.getActualHeight();
|
int height = world.getActualHeight();
|
||||||
int y, dx, dz, blockID;
|
int[] gaps = new int[9];
|
||||||
boolean isSafe;
|
|
||||||
boolean hasBlocks;
|
|
||||||
Block block;
|
|
||||||
int layers = 0;
|
|
||||||
|
|
||||||
// Check if a 3x3 layer of blocks is empty
|
// Check 3x3 layers of blocks for air spaces
|
||||||
// If we find a layer that contains replaceable blocks, it can
|
for (y = Math.min(startY, height - 1); y > 0; y--)
|
||||||
// serve as the base where we'll place the player and door.
|
|
||||||
for (y = Math.min(startY + 2, height - 1); y >= 0; y--)
|
|
||||||
{
|
{
|
||||||
isSafe = true;
|
for (dx = -1, index = 0; dx <= 1; dx++)
|
||||||
hasBlocks = false;
|
|
||||||
for (dx = -1; dx <= 1 && isSafe; dx++)
|
|
||||||
{
|
{
|
||||||
for (dz = -1; dz <= 1 && isSafe; dz++)
|
for (dz = -1; dz <= 1; dz++, index++)
|
||||||
{
|
{
|
||||||
blockID = chunk.getBlockID(localX + dx, y, localZ + dz);
|
if (chunk.getBlockID(localX + dx, y, localZ + dz) != 0)
|
||||||
if (blockID != 0)
|
|
||||||
{
|
{
|
||||||
block = Block.blocksList[blockID];
|
gaps[index] = 0;
|
||||||
if (!block.blockMaterial.isReplaceable())
|
|
||||||
{
|
|
||||||
if (layers >= 3)
|
|
||||||
{
|
|
||||||
return new Point3D(localX + cornerX, y + 1, localZ + cornerZ);
|
|
||||||
}
|
}
|
||||||
isSafe = false;
|
else
|
||||||
}
|
{
|
||||||
hasBlocks = true;
|
gaps[index]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isSafe)
|
// Check if an acceptable gap exists in the center of the search column
|
||||||
|
if (gaps[index / 2] == GAP_HEIGHT)
|
||||||
{
|
{
|
||||||
layers++;
|
return new Point3D(localX + cornerX, y + GAP_HEIGHT - 1, localZ + cornerZ);
|
||||||
if (hasBlocks)
|
}
|
||||||
|
// Check the other positions in the column
|
||||||
|
for (dx = -1, index = 0; dx <= 1; dx++)
|
||||||
{
|
{
|
||||||
if (layers >= 3)
|
for (dz = -1; dz <= 1; dz++, index++)
|
||||||
{
|
{
|
||||||
return new Point3D(localX + cornerX, y, localZ + cornerZ);
|
if (gaps[index] == GAP_HEIGHT)
|
||||||
}
|
{
|
||||||
layers = 0;
|
return new Point3D(localX + cornerX + dx, y + GAP_HEIGHT - 1, localZ + cornerZ + dz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;*/
|
}
|
||||||
// Temporary measure to not break the build
|
return null;
|
||||||
return new Point3D(x, y - 2, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int adjustDestinationY(int y, int worldHeight, int entranceY, int dungeonHeight)
|
public static int adjustDestinationY(int y, int worldHeight, int entranceY, int dungeonHeight)
|
||||||
|
|||||||
Reference in New Issue
Block a user