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 java.io.File;
import StevenDimDoors.mod_pocketDim.world.LimboGenerator;
import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Configuration;
public class DDProperties public class DDProperties
@@ -99,8 +101,9 @@ public class DDProperties
public final int NonTntWeight; public final int NonTntWeight;
public final int RiftSpreadModifier; public final int RiftSpreadModifier;
public final int DungeonRiftGenDensity; public final int ClusterGenerationChance;
public final int MonolithSpawnDensity; public final int GatewayGenerationChance;
public final int MonolithSpawningChance;
public final int LimboReturnRange; public final int LimboReturnRange;
public final String CustomSchematicDirectory; public final String CustomSchematicDirectory;
@@ -200,11 +203,17 @@ public class DDProperties
WorldRiftGenerationEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Rift World Generation", true, WorldRiftGenerationEnabled = config.get(Configuration.CATEGORY_GENERAL, "Enable Rift World Generation", true,
"Sets whether dungeon rifts generate in dimensions other than Limbo").getBoolean(true); "Sets whether dungeon rifts generate in dimensions other than Limbo").getBoolean(true);
MonolithSpawnDensity = config.get(Configuration.CATEGORY_GENERAL, "Enable Rift World Generation", 7, MonolithSpawningChance = config.get(Configuration.CATEGORY_GENERAL, "Monolith Spawning Chance", 28,
"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(); "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, ClusterGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Cluster Generation Chance", 3,
"Sets the dungeon rift density in the overworld, higher values mean less rifts, must be greater than 0. Default is 250.").getInt(); "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, 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. " + "Sets the number of times a rift can spread. 0 prevents rifts from spreading at all. " +

View File

@@ -2,16 +2,24 @@ package StevenDimDoors.mod_pocketDim;
import java.util.Random; import java.util.Random;
import StevenDimDoors.mod_pocketDim.helpers.dimHelper;
import StevenDimDoors.mod_pocketDim.items.ItemRiftBlade;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider; 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; import cpw.mods.fml.common.IWorldGenerator;
public class RiftGenerator implements 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 minableBlockId;
private int numberOfBlocks; private int numberOfBlocks;
int cycles=40; int cycles=40;
@@ -25,6 +33,10 @@ public class RiftGenerator implements IWorldGenerator
LinkData link; LinkData link;
DimData dimData; 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; private static DDProperties properties = null;
public RiftGenerator() public RiftGenerator()
@@ -36,27 +48,14 @@ public class RiftGenerator implements IWorldGenerator
@Override @Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
{ {
//Long ntime = System.nanoTime(); //TODO: This code could really use some cleaning up... ~SenseiKiwi
shouldGenHere=true;
if (world.provider.getDimensionName()=="PocketDim"|| !properties.WorldRiftGenerationEnabled || world.isRemote) shouldGenHere = properties.WorldRiftGenerationEnabled && !(world.provider instanceof pocketProvider) && !world.isRemote;
{
this.shouldGenHere=false; if (shouldGenHere && random.nextInt(MAX_CLUSTER_GENERATION_CHANCE) < properties.ClusterGenerationChance)
}
if(this.shouldGenHere)
{
//TODO give this a clamp int type functionality
if(random.nextInt(3000+properties.DungeonRiftGenDensity*4)==0)
{ {
i = chunkX * 16 - random.nextInt(16); i = chunkX * 16 - random.nextInt(16);
k = chunkZ * 16 - random.nextInt(16); k = chunkZ * 16 - random.nextInt(16);
j = world.getHeightValue(i, k); j = world.getHeightValue(i, k);
if (j > 20 && world.getBlockId(i, j, k) == 0) if (j > 20 && world.getBlockId(i, j, k) == 0)
@@ -67,14 +66,11 @@ public class RiftGenerator implements IWorldGenerator
link = dimHelper.instance.createPocket(link,true, true); link = dimHelper.instance.createPocket(link,true, true);
this.shouldSave=true; this.shouldSave=true;
// SchematicLoader loader = new SchematicLoader(); // SchematicLoader loader = new SchematicLoader();
// loader.init(link); // loader.init(link);
// loader.generateSchematic(link); // loader.generateSchematic(link);
count = 0; count = 0;
while(random.nextInt(4)!=1) while (random.nextInt(MAX_CLUSTER_GROWTH_CHANCE) < CLUSTER_GROWTH_CHANCE)
{ {
i = chunkX * 16 - random.nextInt(16); i = chunkX * 16 - random.nextInt(16);
k = chunkZ * 16 - random.nextInt(16); k = chunkZ * 16 - random.nextInt(16);
@@ -83,74 +79,13 @@ public class RiftGenerator implements IWorldGenerator
if (world.isAirBlock(i, j + 1, 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 (shouldGenHere && random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < properties.GatewayGenerationChance)
if(random.nextInt(properties.DungeonRiftGenDensity)==0&&world.provider.getDimensionName()!="PocketDim"&&!world.isRemote && properties.WorldRiftGenerationEnabled)
{ {
// System.out.println("tryingToGen"); // System.out.println("tryingToGen");
int blockID = Block.stoneBrick.blockID; int blockID = Block.stoneBrick.blockID;
@@ -165,16 +100,10 @@ public class RiftGenerator implements IWorldGenerator
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"); //System.out.println(String.valueOf(i)+"x "+String.valueOf(j)+"y "+String.valueOf(k)+"z"+"small gen");
count=0; count=0;
if(world.isAirBlock(i, j+1, k)) if(world.isAirBlock(i, j+1, k))
{ {
if(world.isBlockOpaqueCube(i, j-2, k)||world.isBlockOpaqueCube(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)); 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);
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 class LimboGenerator extends ChunkProviderGenerate implements IChunkProvider
{ {
public static final int MAX_MONOLITH_SPAWNING_CHANCE = 100;
private static Random rand; private static Random rand;
/** A NoiseGeneratorOctaves used in generating terrain */ /** A NoiseGeneratorOctaves used in generating terrain */
@@ -177,13 +178,8 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
@Override @Override
public void populate(IChunkProvider var1, int var2, int var3) public void populate(IChunkProvider var1, int var2, int var3)
{ {
if (rand.nextInt(MAX_MONOLITH_SPAWNING_CHANCE) < properties.MonolithSpawningChance)
if(rand.nextInt(properties.MonolithSpawnDensity)>1)
{ {
return;
}
int y =0; int y =0;
int x = var2*16 + rand.nextInt(16); int x = var2*16 + rand.nextInt(16);
int z = var3*16 + rand.nextInt(16); int z = var3*16 + rand.nextInt(16);
@@ -212,14 +208,7 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
} }
while (yTest > y); while (yTest > y);
}
// TODO Auto-generated method stub
} }
@Override @Override

View File

@@ -15,7 +15,6 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class pocketProvider extends WorldProvider public class pocketProvider extends WorldProvider
{ {
public int exitXCoord; public int exitXCoord;
public int exitYCoord; public int exitYCoord;
@@ -40,6 +39,7 @@ public class pocketProvider extends WorldProvider
super.worldChunkMgr = new WorldChunkManagerHell(mod_pocketDim.pocketBiome,1,1); super.worldChunkMgr = new WorldChunkManagerHell(mod_pocketDim.pocketBiome,1,1);
//this.dimensionId = ConfigAtum.dimensionID; //this.dimensionId = ConfigAtum.dimensionID;
} }
@Override @Override
public String getSaveFolder() public String getSaveFolder()
{ {
@@ -69,21 +69,25 @@ public class pocketProvider extends WorldProvider
return this.worldObj.getWorldVec3Pool().getVecFromPool((double)0, (double)0, (double)0); return this.worldObj.getWorldVec3Pool().getVecFromPool((double)0, (double)0, (double)0);
} }
@Override @Override
public double getHorizon() public double getHorizon()
{ {
return worldObj.getHeight(); return worldObj.getHeight();
} }
@Override @Override
public IChunkProvider createChunkGenerator() public IChunkProvider createChunkGenerator()
{ {
return new pocketGenerator(worldObj, dimensionId, false); return new pocketGenerator(worldObj, dimensionId, false);
} }
@Override @Override
public boolean canSnowAt(int x, int y, int z) public boolean canSnowAt(int x, int y, int z)
{ {
return false; return false;
} }
public boolean canBlockFreeze(int x, int y, int z, boolean byWater) public boolean canBlockFreeze(int x, int y, int z, boolean byWater)
{ {
return false; return false;
@@ -92,10 +96,12 @@ public class pocketProvider extends WorldProvider
@Override @Override
public String getDimensionName() 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; return "PocketDim " + this.dimensionId;
} }
public int getRespawnDimension(EntityPlayerMP player) public int getRespawnDimension(EntityPlayerMP player)
{ {
int respawnDim; int respawnDim;
@@ -120,7 +126,4 @@ public class pocketProvider extends WorldProvider
{ {
return false; return false;
} }
} }