Fixed Configuration and Rift Generation Bugs
Although fields were created in DDProperties for Monolith spawning and Rift generation, they were mislabeled as reading the "World Rift Generation Enabled" property. I gave them proper names. I also changed the fields and names to be more intuitive and rewrote the descriptions. For instance, "MonolithSpawnDensity" is a misnomer because as density increases, there should be more Monoliths, not less. Now the properties clearly state how they affect a feature. I rewrote the conditions that used each property to correspond with those simplified descriptions and gave the properties default values that will match the generation rates seen before. I also made the rift generation code less cryptic and fixed a bug; there was a check that compared if a dimension was a pocket dimension by its name to prevent rift generation. That name check was wrong - it would never work. Now we check if the provider is an instance of pocketProvider. That will continue working even if we change the way that pocket dimensions are named.
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user