Major Improvements to DungeonHelper, Minor Bug Fixes and Tweaks #25
@@ -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,11 +203,17 @@ 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. " +
|
||||
|
||||
@@ -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;
|
||||
@@ -25,6 +33,10 @@ public class RiftGenerator implements IWorldGenerator
|
||||
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()
|
||||
@@ -36,27 +48,14 @@ 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;
|
||||
|
||||
this.shouldGenHere=false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(this.shouldGenHere)
|
||||
{
|
||||
|
||||
//TODO give this a clamp int type functionality
|
||||
if(random.nextInt(3000+properties.DungeonRiftGenDensity*4)==0)
|
||||
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);
|
||||
|
||||
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);
|
||||
this.shouldSave=true;
|
||||
|
||||
|
||||
// SchematicLoader loader = new SchematicLoader();
|
||||
// loader.init(link);
|
||||
// loader.generateSchematic(link);
|
||||
|
||||
|
||||
count = 0;
|
||||
while(random.nextInt(4)!=1)
|
||||
while (random.nextInt(MAX_CLUSTER_GROWTH_CHANCE) < CLUSTER_GROWTH_CHANCE)
|
||||
{
|
||||
i = chunkX * 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))
|
||||
{
|
||||
|
||||
|
||||
|
||||
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;
|
||||
@@ -165,16 +100,10 @@ public class RiftGenerator implements IWorldGenerator
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
@@ -177,13 +178,8 @@ public class LimboGenerator extends ChunkProviderGenerate implements IChunkProvi
|
||||
@Override
|
||||
public void populate(IChunkProvider var1, int var2, int var3)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if(rand.nextInt(properties.MonolithSpawnDensity)>1)
|
||||
if (rand.nextInt(MAX_MONOLITH_SPAWNING_CHANCE) < properties.MonolithSpawningChance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int y =0;
|
||||
int x = var2*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);
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,6 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class pocketProvider extends WorldProvider
|
||||
|
||||
{
|
||||
public int exitXCoord;
|
||||
public int exitYCoord;
|
||||
@@ -40,6 +39,7 @@ public class pocketProvider extends WorldProvider
|
||||
super.worldChunkMgr = new WorldChunkManagerHell(mod_pocketDim.pocketBiome,1,1);
|
||||
//this.dimensionId = ConfigAtum.dimensionID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSaveFolder()
|
||||
{
|
||||
@@ -69,21 +69,25 @@ public class pocketProvider extends WorldProvider
|
||||
return this.worldObj.getWorldVec3Pool().getVecFromPool((double)0, (double)0, (double)0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHorizon()
|
||||
{
|
||||
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;
|
||||
@@ -92,10 +96,12 @@ public class pocketProvider extends WorldProvider
|
||||
@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;
|
||||
@@ -120,7 +126,4 @@ public class pocketProvider extends WorldProvider
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user