Reworked dimension population
other mods shouldnt attempt to generate in pockets/limbo now. Expect pockets to gen 40x faster on hexxit
This commit is contained in:
@@ -3,6 +3,7 @@ package StevenDimDoors.mod_pocketDim.world;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import StevenDimDoors.mod_pocketDim.CommonTickHandler;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
@@ -33,7 +34,6 @@ import net.minecraftforge.event.terraingen.ChunkProviderEvent;
|
||||
|
||||
public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvider
|
||||
{
|
||||
public static final int MAX_MONOLITH_SPAWNING_CHANCE = 100;
|
||||
private static Random rand;
|
||||
|
||||
/** A NoiseGeneratorOctaves used in generating terrain */
|
||||
@@ -158,15 +158,17 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
|
||||
this.rand.setSeed((long)par1 * 341873128712L + (long)par2 * 132897987541L);
|
||||
byte[] var3 = new byte[32768];
|
||||
this.generateTerrain(par1, par2, var3);
|
||||
this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);
|
||||
|
||||
|
||||
|
||||
|
||||
Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);
|
||||
|
||||
|
||||
var4.generateSkylightMap();
|
||||
|
||||
if(!var4.isTerrainPopulated)
|
||||
{
|
||||
var4.isTerrainPopulated=true;
|
||||
CommonTickHandler.chunksToPopulate.add(new int[] {properties.LimboDimensionID,par1,par2});
|
||||
}
|
||||
|
||||
|
||||
|
||||
return var4;
|
||||
}
|
||||
@Override
|
||||
@@ -178,50 +180,7 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
|
||||
@Override
|
||||
public void populate(IChunkProvider var1, int var2, int var3)
|
||||
{
|
||||
if (rand.nextInt(MAX_MONOLITH_SPAWNING_CHANCE) < properties.MonolithSpawningChance)
|
||||
{
|
||||
int y =0;
|
||||
int x = var2*16 + rand.nextInt(16);
|
||||
int z = var3*16 + rand.nextInt(16);
|
||||
int yTest;
|
||||
do
|
||||
{
|
||||
|
||||
x = var2*16 + rand.nextInt(16);
|
||||
z = var3*16 + rand.nextInt(16);
|
||||
|
||||
while(this.worldObj.getBlockId(x, y, z)==0&&y<255)
|
||||
{
|
||||
y++;
|
||||
}
|
||||
y = yCoordHelper.getFirstUncovered(this.worldObj,x , y+2, z);
|
||||
|
||||
yTest=yCoordHelper.getFirstUncovered(this.worldObj,x , y+5, z);
|
||||
if(yTest>245)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int jumpSanity=0;
|
||||
int jumpHeight=0;
|
||||
do
|
||||
{
|
||||
jumpHeight = y+rand.nextInt(25);
|
||||
|
||||
jumpSanity++;
|
||||
}
|
||||
while(!this.worldObj.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
|
||||
|
||||
|
||||
Entity mob = new MobObelisk(this.worldObj);
|
||||
mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
|
||||
|
||||
|
||||
this.worldObj.spawnEntityInWorld(mob);
|
||||
|
||||
}
|
||||
while (yTest > y);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.ChunkProviderGenerate;
|
||||
import StevenDimDoors.mod_pocketDim.CommonTickHandler;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.DimData;
|
||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
|
||||
@@ -23,13 +25,17 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
||||
{
|
||||
private World worldObj;
|
||||
|
||||
private static final int MAX_MONOLITH_SPAWN_Y = 245;
|
||||
private static final int CHUNK_SIZE = 16;
|
||||
private DDProperties properties = null;
|
||||
|
||||
|
||||
|
||||
public PocketGenerator(World par1World, long par2, boolean par4)
|
||||
{
|
||||
super(par1World, par2, par4);
|
||||
this.worldObj = par1World;
|
||||
|
||||
if (properties == null)
|
||||
properties = DDProperties.instance();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,6 +55,12 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
||||
byte[] var3 = new byte[32768];
|
||||
|
||||
Chunk chunk = new Chunk(worldObj, var3, chunkX, chunkZ);
|
||||
|
||||
if(!chunk.isTerrainPopulated)
|
||||
{
|
||||
chunk.isTerrainPopulated=true;
|
||||
CommonTickHandler.chunksToPopulate.add(new int[] {chunk.worldObj.provider.dimensionId,chunkX,chunkZ});
|
||||
}
|
||||
|
||||
return chunk;
|
||||
}
|
||||
@@ -62,81 +74,7 @@ public class PocketGenerator extends ChunkProviderGenerate implements IChunkProv
|
||||
@Override
|
||||
public void populate(IChunkProvider chunkProvider, int chunkX, int chunkZ)
|
||||
{
|
||||
//Check whether we want to populate this chunk with Monoliths.
|
||||
DimData dimData = dimHelper.dimList.get(worldObj.provider.dimensionId);
|
||||
int sanity = 0;
|
||||
int blockID = 0;
|
||||
boolean didSpawn=false;
|
||||
|
||||
if (dimData == null ||
|
||||
dimData.dungeonGenerator == null ||
|
||||
dimData.dungeonGenerator.isOpen)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//The following initialization code is based on code from ChunkProviderGenerate.
|
||||
//It makes our generation depend on the world seed.
|
||||
Random random = new Random(worldObj.getSeed());
|
||||
long factorA = random.nextLong() / 2L * 2L + 1L;
|
||||
long factorB = random.nextLong() / 2L * 2L + 1L;
|
||||
random.setSeed((long)chunkX * factorA + (long)chunkZ * factorB ^ worldObj.getSeed());
|
||||
|
||||
int x, y, z;
|
||||
do
|
||||
{
|
||||
//Select a random column within the chunk
|
||||
x = chunkX * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
z = chunkZ * CHUNK_SIZE + random.nextInt(CHUNK_SIZE);
|
||||
y = MAX_MONOLITH_SPAWN_Y;
|
||||
blockID = worldObj.getBlockId(x, y, z);
|
||||
|
||||
while (blockID == 0 &&y>0)
|
||||
{
|
||||
y--;
|
||||
blockID = worldObj.getBlockId(x, y, z);
|
||||
|
||||
}
|
||||
while(blockID == mod_pocketDim.blockDimWall.blockID&&y>0)
|
||||
{
|
||||
y--;
|
||||
blockID = worldObj.getBlockId(x, y, z);
|
||||
}
|
||||
while (blockID == 0 &&y>0)
|
||||
{
|
||||
y--;
|
||||
blockID = worldObj.getBlockId(x, y, z);
|
||||
|
||||
}
|
||||
if(y > 0)
|
||||
{
|
||||
|
||||
|
||||
|
||||
int jumpSanity=0;
|
||||
int jumpHeight=0;
|
||||
do
|
||||
{
|
||||
|
||||
jumpHeight = y+random.nextInt(10);
|
||||
|
||||
jumpSanity++;
|
||||
}
|
||||
while(!this.worldObj.isAirBlock(x,jumpHeight+6 , z)&&jumpSanity<20);
|
||||
|
||||
|
||||
|
||||
|
||||
Entity mob = new MobObelisk(worldObj);
|
||||
mob.setLocationAndAngles(x, jumpHeight, z, 1, 1);
|
||||
worldObj.spawnEntityInWorld(mob);
|
||||
didSpawn=true;
|
||||
}
|
||||
|
||||
sanity++;
|
||||
|
||||
}
|
||||
while (sanity<5&&!didSpawn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user