Skip to content

Commit

Permalink
Add Config options to disable doMobSpawning gamerule on server start.
Browse files Browse the repository at this point in the history
Add Config options to empty vanilla spawnLists on server start.
  • Loading branch information
Crudedragos committed Apr 10, 2013
1 parent 5aecb81 commit 672bdf1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/jas/common/JustAnotherSpawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

import java.io.File;

import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.GameRules;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
Expand Down Expand Up @@ -49,7 +51,7 @@ public void preInit(FMLPreInitializationEvent event) {
JASLog.configureLogging(Properties.debugMode);
TickRegistry.registerTickHandler(new SpawnerTicker(), Side.SERVER);
MinecraftForge.TERRAIN_GEN_BUS.register(new ChunkSpawner());
// proxy.registerKeyBinding();
// proxy.registerKeyBinding();
}

@Init
Expand All @@ -68,11 +70,27 @@ public void serverStart(FMLServerStartingEvent event) {
CreatureTypeRegistry.INSTANCE.initializeFromConfig(modConfigDirectoryFile, event.getServer());
CreatureHandlerRegistry.INSTANCE.serverStartup(modConfigDirectoryFile, event.getServer().worldServers[0]);
BiomeHandlerRegistry.INSTANCE.setupHandlers(modConfigDirectoryFile, event.getServer().worldServers[0]);

if (Properties.emptyVanillaSpawnLists) {
for (BiomeGenBase biome : BiomeGenBase.biomeList) {
if (biome == null) {
continue;
}
for (EnumCreatureType type : EnumCreatureType.values()) {
biome.getSpawnableList(type).clear();
}
}
}

GameRules gameRule = event.getServer().worldServerForDimension(0).getGameRules();
if (Properties.turnGameruleSpawningOff) {
gameRule.setOrCreateGameRule("doMobSpawning", "false");
}

String ruleName = "doCustomMobSpawning";
if (gameRule.hasRule(ruleName)) {
} else {
gameRule.addGameRule(ruleName, "true");
}
}
}
}
9 changes: 8 additions & 1 deletion src/jas/common/Properties.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package jas.common;


import java.io.File;

import net.minecraftforge.common.Configuration;
Expand All @@ -11,11 +10,19 @@ public class Properties {
public static int spawnerTickSpacing = 0;
public static boolean sortCreatureByBiome = true;

public static boolean turnGameruleSpawningOff = false;
public static boolean emptyVanillaSpawnLists = false;

public static void loadProperties(File configDirectory) {
Configuration config = new Configuration(
new File(configDirectory, DefaultProps.MODDIR + "GlobalProperties.cfg"));
config.load();
debugMode = config.get("Properties.Logging", "Debug Mode", debugMode).getBoolean(debugMode);
turnGameruleSpawningOff = config.get("Properties.Vanilla Controls", "Gamerule doSpawning Off on Start",
turnGameruleSpawningOff).getBoolean(turnGameruleSpawningOff);
emptyVanillaSpawnLists = config.get("Properties.Vanilla Controls", "Empty Vanilla SpawnLists on Start",
emptyVanillaSpawnLists).getBoolean(emptyVanillaSpawnLists);

sortCreatureByBiome = config.get("Properties.Spawning", "Sort Creature By Biome", sortCreatureByBiome)
.getBoolean(sortCreatureByBiome);
Property resultTickSpacing = config.get("Properties.Spawning", "Spawner Tick Spacing", spawnerTickSpacing);
Expand Down
2 changes: 2 additions & 0 deletions src/jas/common/spawner/creature/handler/LivingHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public LivingHandler(Class<? extends EntityLiving> entityClass, String creatureT
despawning = new OptionalSettingsDespawning(string);
}
}
spawning = spawning == null ? new OptionalSettingsSpawning("") : spawning;
despawning = despawning == null ? new OptionalSettingsDespawning("") : despawning;
}

public final LivingHandler toCreatureTypeID(String creatureTypeID) {
Expand Down
2 changes: 0 additions & 2 deletions src/jas/compatability/tf/BiomeInterpreterTwilightForest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package jas.compatability.tf;

import jas.api.BiomeInterpreter;
import jas.common.JASLog;
import jas.common.spawner.biome.BiomeInterpreterHelper;
import jas.common.spawner.creature.handler.ParsingHelper;
import jas.common.spawner.creature.handler.ReflectionHelper;
Expand Down Expand Up @@ -36,7 +35,6 @@ public Collection<String> getStructureKeys() {
List spawnableMonsterList = ReflectionHelper.getFieldFromReflection("spawnableMonsterLists",
TFFeature.featureList[i], List.class);
if (spawnableMonsterList != null) {
JASLog.info("Feature name %s index %s", TFFeature.featureList[i].name, spawnableMonsterList.size());
for (int j = 0; j < spawnableMonsterList.size(); j++) {
featureNameToID.put(TFFeature.featureList[i].name, i);
collection.add(TFFeature.featureList[i].name + "_" + j);
Expand Down

0 comments on commit 672bdf1

Please sign in to comment.