Added Config Settings for Nether Gateways

Added config settings for the chance of generating a Rift Gateway in a
Nether Fortress. Also made it so that DD does not override Nether
Fortress generation if fortress gateways are disabled in some way.
This commit is contained in:
SenseiKiwi
2014-03-04 04:39:57 -04:00
parent 47f7e280a7
commit 93f2f6c701
4 changed files with 16 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import java.io.File;
import net.minecraftforge.common.Configuration;
import StevenDimDoors.mod_pocketDim.ticking.CustomLimboPopulator;
import StevenDimDoors.mod_pocketDim.world.GatewayGenerator;
import StevenDimDoors.mod_pocketDim.world.fortresses.DDStructureNetherBridgeStart;
public class DDProperties
{
@@ -104,6 +105,7 @@ public class DDProperties
public final int NonTntWeight;
public final int ClusterGenerationChance;
public final int GatewayGenerationChance;
public final int FortressGatewayGenerationChance;
public final int MonolithSpawningChance;
public final int LimboReturnRange;
public final String CustomSchematicDirectory;
@@ -217,6 +219,10 @@ public class DDProperties
"Sets the chance (out of " + GatewayGenerator.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
"generate in a given chunk. The default chance is 15.").getInt();
FortressGatewayGenerationChance = config.get(Configuration.CATEGORY_GENERAL, "Fortress Gateway Generation Chance", 33,
"Sets the chance (out of " + DDStructureNetherBridgeStart.MAX_GATEWAY_GENERATION_CHANCE + ") that a Rift Gateway will " +
"generate as part of a Nether Fortress. The default chance is 33.").getInt();
LimboBiomeID = config.get(CATEGORY_BIOME, "Limbo Biome ID", 251).getInt();
PocketBiomeID = config.get(CATEGORY_BIOME, "Pocket Biome ID", 250).getInt();

View File

@@ -43,7 +43,10 @@ public class EventHookContainer
@ForgeSubscribe(priority = EventPriority.LOW)
public void onMapGen(InitMapGenEvent event)
{
if (event.type == InitMapGenEvent.EventType.NETHER_BRIDGE)
// Replace the Nether fortress generator with our own only if any gateways would ever generate.
// This allows admins to disable our fortress overriding without disabling all gateways.
if (properties.FortressGatewayGenerationChance > 0 && properties.WorldRiftGenerationEnabled &&
event.type == InitMapGenEvent.EventType.NETHER_BRIDGE)
{
event.newGen = new DDNetherFortressGenerator();
}

View File

@@ -1,5 +1,6 @@
package StevenDimDoors.mod_pocketDim.world.fortresses;
import StevenDimDoors.mod_pocketDim.DDProperties;
import net.minecraft.world.gen.structure.MapGenNetherBridge;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraft.world.gen.structure.StructureStart;
@@ -19,6 +20,6 @@ public class DDNetherFortressGenerator extends MapGenNetherBridge
protected StructureStart getStructureStart(int chunkX, int chunkZ)
{
return new DDStructureNetherBridgeStart(this.worldObj, this.rand, chunkX, chunkZ);
return new DDStructureNetherBridgeStart(this.worldObj, this.rand, chunkX, chunkZ, DDProperties.instance());
}
}

View File

@@ -6,16 +6,15 @@ import java.util.Random;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.ComponentNetherBridgeCrossing;
import net.minecraft.world.gen.structure.ComponentNetherBridgeThrone;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
import net.minecraft.world.gen.structure.StructureNetherBridgeStart;
import StevenDimDoors.mod_pocketDim.DDProperties;
public class DDStructureNetherBridgeStart extends StructureNetherBridgeStart
{
private static int GATEWAY_GENERATION_CHANCE = 1;
private static int MAX_GATEWAY_GENERATION_CHANCE = 3;
public static final int MAX_GATEWAY_GENERATION_CHANCE = 100;
private boolean hasGateway;
private int minX;
@@ -24,7 +23,7 @@ public class DDStructureNetherBridgeStart extends StructureNetherBridgeStart
public DDStructureNetherBridgeStart() { }
public DDStructureNetherBridgeStart(World world, Random random, int chunkX, int chunkZ)
public DDStructureNetherBridgeStart(World world, Random random, int chunkX, int chunkZ, DDProperties properties)
{
// StructureNetherBridgeStart handles designing the fortress for us
super(world, random, chunkX, chunkZ);
@@ -36,7 +35,7 @@ public class DDStructureNetherBridgeStart extends StructureNetherBridgeStart
hasGateway = false;
// Randomly decide whether to build a gateway in this fortress
if (random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < GATEWAY_GENERATION_CHANCE)
if (random.nextInt(MAX_GATEWAY_GENERATION_CHANCE) < properties.FortressGatewayGenerationChance)
{
// Search for all the blaze spawners in a fortress
spawnerRooms = new ArrayList<ComponentNetherBridgeThrone>();