Major Improvements to DungeonHelper, Minor Bug Fixes and Tweaks #25

Merged
SenseiKiwi merged 29 commits from master into master 2013-06-16 19:30:26 +00:00
4 changed files with 123 additions and 230 deletions
Showing only changes of commit 697b0da59f - Show all commits

View File

@@ -2,6 +2,8 @@ package StevenDimDoors.mod_pocketDim;
import java.io.File;
import StevenDimDoors.mod_pocketDim.world.LimboGenerator;
import net.minecraftforge.common.Configuration;
public class DDProperties
@@ -99,8 +101,9 @@ public class DDProperties
public final int NonTntWeight;
public final int RiftSpreadModifier;
public final int DungeonRiftGenDensity;
public final int MonolithSpawnDensity;
public final int ClusterGenerationChance;
public final int GatewayGenerationChance;
public final int MonolithSpawningChance;
public final int LimboReturnRange;
public final String CustomSchematicDirectory;
@@ -200,12 +203,18 @@ public class DDProperties
WorldRiftGenerationEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Rift World Generation", true,
"Sets whether dungeon rifts generate in dimensions other than Limbo").getBoolean(true);
MonolithSpawnDensity = config.get(Configuration.CATEGORY_GENERAL, "Enable Rift World Generation", 7,
"Sets the chance that monoliths will not spawn in a give Limbo chunk- higher values mean fewer monoliths, must be greater than 0, default is 7.").getInt();
MonolithSpawningChance = config.get(Configuration.CATEGORY_GENERAL, "Monolith Spawning Chance", 28,
"Sets the chance (out of " + LimboGenerator.MAX_MONOLITH_SPAWNING_CHANCE + ") that Monoliths will " +
"spawn in a given Limbo chunk. The default chance is 28.").getInt();
DungeonRiftGenDensity = config.get(Configuration.CATEGORY_GENERAL, "Enable Rift World Generation", 250,
"Sets the dungeon rift density in the overworld, higher values mean less rifts, must be greater than 0. Default is 250.").getInt();
ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 3,
"Sets the chance (out of " + RiftGenerator.MAX_CLUSTER_GENERATION_CHANCE + ") that a cluster of rifts will " +
"generate in a given chunk. The default chance is 3.").getInt();
GatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Gateway Generation Chance", 40,
"Sets the chance (out of " + RiftGenerator.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
"generate in a given chunk. The default chance is 40.").getInt();
RiftSpreadModifier = config.get(Configuration.CATEGORY_GENERAL, "Rift Spread Modifier", 3,
"Sets the number of times a rift can spread. 0 prevents rifts from spreading at all. " +
"A value greater than 5 is not recommended as the growth is exponential.").getInt();

View File

@@ -2,16 +2,24 @@ package StevenDimDoors.mod_pocketDim;
import java.util.Random;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
import StevenDimDoors.mod_pocketDim.world.pocketProvider;
import cpw.mods.fml.common.IWorldGenerator;
public class RiftGenerator implements IWorldGenerator
{
//TODO: Stop the madness here...
//Based on reviewing the code in this mod, I believe that all IWorldGenerators
//must work as singletons. Given that each call that comes into them is independent,
//we shouldn't have ANY fields in here! At best they will end up causing bugs.
//In particular, using our own instance of Random instead of one derived from the world
//seed means that our chunk generation isn't linked to the world seed. Bad, very bad!
//I'm going to fix this later. <_<;; ~SenseiKiwi
private int minableBlockId;
private int numberOfBlocks;
int cycles=40;
@@ -21,12 +29,16 @@ public class RiftGenerator implements IWorldGenerator
int k;
int j;
Random rand = new Random();
boolean shouldGenHere=true;
boolean shouldGenHere = true;
LinkData link;
DimData dimData;
public static final int MAX_GATEWAY_GENERATION_CHANCE = 10000;
public static final int MAX_CLUSTER_GENERATION_CHANCE = 10000;
private static final int CLUSTER_GROWTH_CHANCE = 80;
private static final int MAX_CLUSTER_GROWTH_CHANCE = 100;
private static DDProperties properties = null;
public RiftGenerator()
{
if (properties == null)
@@ -36,145 +48,62 @@ public class RiftGenerator implements IWorldGenerator
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{
//Long ntime = System.nanoTime();
shouldGenHere=true;
//TODO: This code could really use some cleaning up... ~SenseiKiwi
if (world.provider.getDimensionName()=="PocketDim"|| !properties.WorldRiftGenerationEnabled || world.isRemote)
shouldGenHere = properties.WorldRiftGenerationEnabled && !(world.provider instanceof pocketProvider) && !world.isRemote;
if (shouldGenHere && random.nextInt(MAX_CLUSTER_GENERATION_CHANCE) < properties.ClusterGenerationChance)
{
i = chunkX * 16 - random.nextInt(16);
k = chunkZ * 16 - random.nextInt(16);
j = world.getHeightValue(i, k);
this.shouldGenHere=false;
}
if(this.shouldGenHere)
{
//TODO give this a clamp int type functionality
if(random.nextInt(3000+properties.DungeonRiftGenDensity*4)==0)
if (j > 20 && world.getBlockId(i, j, k) == 0)
{
i=chunkX*16-random.nextInt(16);
k=chunkZ*16-random.nextInt(16);
// System.out.println(String.valueOf(i)+"x "+String.valueOf(j)+"y "+String.valueOf(k)+"z"+"Large gen");
j= world.getHeightValue(i, k);
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true,rand.nextInt(4));
link = dimHelper.instance.createPocket(link,true, true);
this.shouldSave=true;
if(j>20&&world.getBlockId(i, j, k)==0)
// SchematicLoader loader = new SchematicLoader();
// loader.init(link);
// loader.generateSchematic(link);
count = 0;
while (random.nextInt(MAX_CLUSTER_GROWTH_CHANCE) < CLUSTER_GROWTH_CHANCE)
{
// System.out.println(String.valueOf(i)+"x "+String.valueOf(j)+"y "+String.valueOf(k)+"z"+"Large gen");
i = chunkX * 16 - random.nextInt(16);
k = chunkZ * 16 - random.nextInt(16);
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true,rand.nextInt(4));
link = dimHelper.instance.createPocket(link,true, true);
this.shouldSave=true;
j = world.getHeightValue(i, k);
// SchematicLoader loader = new SchematicLoader();
// loader.init(link);
// loader.generateSchematic(link);
count=0;
while(random.nextInt(4)!=1)
if (world.isAirBlock(i, j + 1, k))
{
i=chunkX*16-random.nextInt(16);
k=chunkZ*16-random.nextInt(16);
j= world.getHeightValue(i, k);
if(world.isAirBlock(i, j+1, k))
{
link = dimHelper.instance.createLink(link.locDimID,link.destDimID, i, j+1, k,link.destXCoord,link.destYCoord,link.destZCoord);
}
link = dimHelper.instance.createLink(link.locDimID,link.destDimID, i, j+1, k,link.destXCoord,link.destYCoord,link.destZCoord);
}
}
}
/**
if(random.nextInt(540)==0)
{
i=chunkX*16-random.nextInt(16);
k=chunkZ*16-random.nextInt(16);
j= world.getHeightValue(i, k);
if(j>20&&world.getBlockId(i, j, k)==0)
{
//System.out.println(String.valueOf(i)+"x "+String.valueOf(j)+"y "+String.valueOf(k)+"z"+"med gen");
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true,rand.nextInt(4));
link = dimHelper.instance.createPocket(link,true, true);
this.shouldSave=true;
// SchematicLoader loader = new SchematicLoader();
// loader.init(link);
// loader.generateSchematic(link);
count=0;
while(random.nextInt(3)!=1)
{
i=chunkX*16-random.nextInt(16);
k=chunkZ*16-random.nextInt(16);
j= world.getHeightValue(i, k);
if(world.isAirBlock(i, j+1, k))
{
link = dimHelper.instance.createLink(link.locDimID,link.destDimID, i, j+1, k,link.destXCoord,link.destYCoord,link.destZCoord);
}
}
}
}
**/
}
if(random.nextInt(properties.DungeonRiftGenDensity)==0&&world.provider.getDimensionName()!="PocketDim"&&!world.isRemote && properties.WorldRiftGenerationEnabled)
if (shouldGenHere && random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < properties.GatewayGenerationChance)
{
// System.out.println("tryingToGen");
int blockID=Block.stoneBrick.blockID;
if(world.provider.dimensionId==properties.LimboDimensionID)
int blockID = Block.stoneBrick.blockID;
if (world.provider.dimensionId == properties.LimboDimensionID)
{
blockID= properties.LimboBlockID;
blockID = properties.LimboBlockID;
}
i=chunkX*16-random.nextInt(16);
k=chunkZ*16-random.nextInt(16);
j= world.getHeightValue(i, k);
if(j>20&&world.getBlockId(i, j, k)==0)
if(j>20 && world.getBlockId(i, j, k)==0)
{
//System.out.println(String.valueOf(i)+"x "+String.valueOf(j)+"y "+String.valueOf(k)+"z"+"small gen");
count=0;
if(world.isAirBlock(i, j+1, k))
{
if(world.isBlockOpaqueCube(i, j-2, k)||world.isBlockOpaqueCube(i, j-1, k))
{
link = new LinkData(world.provider.dimensionId, 0, i, j+1, k, i, j+1, k, true,rand.nextInt(4));
@@ -216,47 +145,10 @@ public class RiftGenerator implements IWorldGenerator
world.setBlock(i, j+2, k+1, blockID,3,1);
world.setBlock(i, j+2, k-1, blockID,3,1);
}
this.shouldSave=true;
this.shouldSave = true;
}
// dimData = dimHelper.instance.dimList.get(link.destDimID);
// SchematicLoader loader = new SchematicLoader();
// loader.init(link);
// loader.generateSchematic(link);
}
}
}
if(this.shouldSave)
{
// dimHelper.instance.save();
}
// mod_pocketDim.genTime=((System.nanoTime()-ntime)+mod_pocketDim.genTime);
// System.out.println( mod_pocketDim.genTime);
// System.out.println( (System.nanoTime()-ntime));
// ntime=0L;
}
}

View File

@@ -33,6 +33,7 @@ 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 */
@@ -108,7 +109,7 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
{
// caveGenerator = TerrainGen.getModdedMapGen(caveGenerator, CAVE);
}
private static DDProperties properties = null;
public LimboGenerator(World par1World, long par2)
@@ -135,7 +136,7 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
this.mobSpawnerNoise = noiseGens[6];
// TODO Auto-generated constructor stub
this.worldObj=par1World;
if (properties == null)
properties = DDProperties.instance();
}
@@ -177,49 +178,37 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
@Override
public void populate(IChunkProvider var1, int var2, int var3)
{
if(rand.nextInt(properties.MonolithSpawnDensity)>1)
{
return;
}
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);
Entity mob = new MobObelisk(this.worldObj);
mob.setLocationAndAngles(x, y, z, 1, 1);
yTest=yCoordHelper.getFirstUncovered(this.worldObj,x , y+5, z);
if(yTest>245)
{
return;
}
this.worldObj.spawnEntityInWorld(mob);
}
while(yTest >y);
// TODO Auto-generated method stub
while (yTest > y);
}
}
@Override

View File

@@ -15,112 +15,115 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class pocketProvider extends WorldProvider
{
public int exitXCoord;
public int exitYCoord;
public int exitZCoord;
public int exitDimID;
public boolean hasNoSky = true;
public boolean isSavingSchematic= false;
public int dimToSave;
private static DDProperties properties = null;
public pocketProvider()
{
this.hasNoSky=true;
if (properties == null)
properties = DDProperties.instance();
}
@Override
protected void registerWorldChunkManager()
{
protected void registerWorldChunkManager()
{
super.worldChunkMgr = new WorldChunkManagerHell(mod_pocketDim.pocketBiome,1,1);
//this.dimensionId = ConfigAtum.dimensionID;
}
//this.dimensionId = ConfigAtum.dimensionID;
}
@Override
public String getSaveFolder()
{
return (dimensionId == 0 ? null : "DimensionalDoors/pocketDimID" + dimensionId);
}
{
return (dimensionId == 0 ? null : "DimensionalDoors/pocketDimID" + dimensionId);
}
public void saveAsSchematic(int id)
{
this.isSavingSchematic=true;
this.dimensionId=id;
}
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks)
{
setCloudRenderer( new CloudRenderBlank());
return this.worldObj.getWorldVec3Pool().getVecFromPool((double)0, (double)0, (double)0);
setCloudRenderer( new CloudRenderBlank());
return this.worldObj.getWorldVec3Pool().getVecFromPool((double)0, (double)0, (double)0);
}
@SideOnly(Side.CLIENT)
@SideOnly(Side.CLIENT)
@Override
public Vec3 getFogColor(float par1, float par2)
{
return this.worldObj.getWorldVec3Pool().getVecFromPool((double)0, (double)0, (double)0);
{
return this.worldObj.getWorldVec3Pool().getVecFromPool((double)0, (double)0, (double)0);
}
}
@Override
public double getHorizon()
{
return worldObj.getHeight();
}
{
return worldObj.getHeight();
}
@Override
public IChunkProvider createChunkGenerator()
{
return new pocketGenerator(worldObj, dimensionId, false);
}
@Override
public boolean canSnowAt(int x, int y, int z)
{
return false;
}
public boolean canBlockFreeze(int x, int y, int z, boolean byWater)
{
return false;
}
@Override
public boolean canSnowAt(int x, int y, int z)
{
return false;
}
public boolean canBlockFreeze(int x, int y, int z, boolean byWater)
{
return false;
}
@Override
public String getDimensionName()
{
//TODO: This should be a proper name. We need to show people proper names for things whenever possible.
//The question is whether this should be "Pocket Dimension" or "Pocket Dimension #" -- I'm not going to change
//it out of concern that it could break something. ~SenseiKiwi
return "PocketDim " + this.dimensionId;
}
public int getRespawnDimension(EntityPlayerMP player)
{
int respawnDim;
if (properties.LimboEnabled)
{
respawnDim = properties.LimboDimensionID;
}
else
{
respawnDim= dimHelper.dimList.get(this.dimensionId).exitDimLink.destDimID;
respawnDim = dimHelper.dimList.get(this.dimensionId).exitDimLink.destDimID;
}
if (dimHelper.getWorld(respawnDim)==null)
if (dimHelper.getWorld(respawnDim) == null)
{
dimHelper.initDimension(respawnDim);
}
return respawnDim;
}
public boolean canRespawnHere()
{
return false;
}
public boolean canRespawnHere()
{
return false;
}
}