Improved PocketGenerator
Improved code in PocketGenerator. Restricted Monolith generation to the chunk in which populate() is being applied. We should not be generating Monoliths outside that chunk. Changed condition that would exit the function if the next available space for a Monolith was above Y = 245. Exiting the function at that point made no sense. I've realized that this placement algorithm has probably been patched up several times and that's resulted in nonsensical code. For instance, the loop continues as long as you continue finding higher points to place Monoliths. That would suggest you intended to make columns of them. But since the loop chooses random columns on each iteration goes back to Y = 0, you're really just jumping around and placing Monoliths in random places, while using irrelevant checks to decide whether to continue. I really recommend coming up with a different algorithm. I haven't replaced it completely in case it would break something.
This commit is contained in:
@@ -20,6 +20,9 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
|||||||
{
|
{
|
||||||
private World worldObj;
|
private World worldObj;
|
||||||
|
|
||||||
|
private static final int MAX_MONOLITH_SPAWN_Y = 245;
|
||||||
|
private static final int CHUNK_SIZE = 16;
|
||||||
|
|
||||||
public PocketGenerator(World par1World, long par2, boolean par4)
|
public PocketGenerator(World par1World, long par2, boolean par4)
|
||||||
{
|
{
|
||||||
super(par1World, par2, par4);
|
super(par1World, par2, par4);
|
||||||
@@ -76,8 +79,9 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
|||||||
int x, y, z;
|
int x, y, z;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
x = chunkX * 16 + random.nextInt(32) - 8;
|
//Select a random column within the chunk
|
||||||
z = chunkZ * 16 + random.nextInt(32) - 8;
|
x = chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||||
|
z = chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|
||||||
while (worldObj.getBlockId(x, y, z) == 0 && y < 255)
|
while (worldObj.getBlockId(x, y, z) == 0 && y < 255)
|
||||||
@@ -86,17 +90,16 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
|||||||
}
|
}
|
||||||
y = yCoordHelper.getFirstUncovered(worldObj,x , y + 2, z);
|
y = yCoordHelper.getFirstUncovered(worldObj,x , y + 2, z);
|
||||||
|
|
||||||
if (worldObj.getBlockId(x, y-1, z) != mod_pocketDim.blockDimWall.blockID)
|
if (worldObj.getBlockId(x, y - 1, z) != mod_pocketDim.blockDimWall.blockID)
|
||||||
{
|
{
|
||||||
y = y + random.nextInt(4)+2;
|
y += random.nextInt(4) + 2;
|
||||||
}
|
}
|
||||||
if (y > 245)
|
if (y <= MAX_MONOLITH_SPAWN_Y)
|
||||||
{
|
{
|
||||||
return;
|
Entity mob = new MobObelisk(worldObj);
|
||||||
|
mob.setLocationAndAngles(x, y, z, 1, 1);
|
||||||
|
worldObj.spawnEntityInWorld(mob);
|
||||||
}
|
}
|
||||||
Entity mob = new MobObelisk(worldObj);
|
|
||||||
mob.setLocationAndAngles(x, y, z, 1, 1);
|
|
||||||
worldObj.spawnEntityInWorld(mob);
|
|
||||||
}
|
}
|
||||||
while (yCoordHelper.getFirstUncovered(worldObj, x , y, z) > y || random.nextBoolean());
|
while (yCoordHelper.getFirstUncovered(worldObj, x , y, z) > y || random.nextBoolean());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user