Fixed Gen Directionality Bug and Minor Tweak

I fixed a subtle bug in RiftGenerator. The code for picking random
coordinates on the surface of a chunk would subtract a random amount
from the coordinate of the chunk's corner. Unfortunately, subtracting
meant that we would almost always generate coordinates OUTSIDE the
intended chunk. The correct calculation was to add, not subtract. This
meant that if you walked in a direction in which our gateways were
generated outside of existing chunks, then their data would be lost and
no gateways would generate!

To reproduce this bug, max out the chance of generating gateways and fly
in the direction that decreases X and Z. You must fly into new chunks.
After passing the gateways produced when you spawn (if this is a new
world) you'll see that gateways don't generate on the landscape.
However, if you change directions, they'll begin generating again.

In addition to fixing that bug, I also tweaked all the block setting
calls in RiftGenerator so that they'll trigger block updates and send
update packets to the client. I think triggering block updates will
prevent unusual problems with floating sand, gravel, etc.
This commit is contained in:
SenseiKiwi
2013-06-17 03:38:10 -04:00
parent 4ceace1b47
commit e7b064e3cb

View File

@@ -52,8 +52,8 @@ public class RiftGenerator implements IWorldGenerator
do
{
//Pick a random point on the surface of the chunk
x = chunkX * CHUNK_LENGTH - random.nextInt(CHUNK_LENGTH);
z = chunkZ * CHUNK_LENGTH - random.nextInt(CHUNK_LENGTH);
x = chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
z = chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
y = world.getHeightValue(x, z);
//If the point is within the acceptable altitude range and the block above is empty, then place a rift
@@ -86,8 +86,8 @@ public class RiftGenerator implements IWorldGenerator
do
{
//Pick a random point on the surface of the chunk
x = chunkX * CHUNK_LENGTH - random.nextInt(CHUNK_LENGTH);
z = chunkZ * CHUNK_LENGTH - random.nextInt(CHUNK_LENGTH);
x = chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
z = chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
y = world.getHeightValue(x, z);
valid = checkGatewayLocation(world, x, y, z);
attempts++;
@@ -122,38 +122,38 @@ public class RiftGenerator implements IWorldGenerator
if (Math.abs(xc) + Math.abs(zc) < random.nextInt(2) + 3)
{
//Place Stone Bricks
world.setBlock(x + xc, y - 1, z + zc, blockID,0,2);
world.setBlock(x + xc, y - 1, z + zc, blockID, 0, 3);
}
else if (Math.abs(xc) + Math.abs(zc) < random.nextInt(3) + 3)
{
//Place Cracked Stone Bricks
world.setBlock(x + xc, y - 1, z + zc, blockID, 2, 2);
world.setBlock(x + xc, y - 1, z + zc, blockID, 2, 3);
}
}
}
}
//Use Chiseled Stone Bricks to top off the pillars around the door
world.setBlock(x, y + 2, z + 1, blockID, 3, 2);
world.setBlock(x, y + 2, z - 1, blockID, 3, 2);
world.setBlock(x, y + 2, z + 1, blockID, 3, 3);
world.setBlock(x, y + 2, z - 1, blockID, 3, 3);
}
else
{
//Build the gateway out of Unraveled Fabric. Since nearly all the blocks in Limbo are of
//that type, there is no point replacing the ground. Just build the tops of the columns here.
blockID = properties.LimboBlockID;
world.setBlock(x, y + 2, z + 1, blockID, 0, 2);
world.setBlock(x, y + 2, z - 1, blockID, 0, 2);
world.setBlock(x, y + 2, z + 1, blockID, 0, 3);
world.setBlock(x, y + 2, z - 1, blockID, 0, 3);
}
//Place the shiny transient door into a dungeon
ItemRiftBlade.placeDoorBlock(world, x, y + 1, z, 0, mod_pocketDim.transientDoor);
//Build the columns around the door
world.setBlock(x, y + 1, z - 1, blockID, 0, 2);
world.setBlock(x, y + 1, z + 1, blockID, 0, 2);
world.setBlock(x, y, z - 1, blockID, 0, 2);
world.setBlock(x, y, z + 1, blockID, 0, 2);
world.setBlock(x, y + 1, z - 1, blockID, 0, 3);
world.setBlock(x, y + 1, z + 1, blockID, 0, 3);
world.setBlock(x, y, z - 1, blockID, 0, 3);
world.setBlock(x, y, z + 1, blockID, 0, 3);
}
}
}