Added a config option for the BoP worldtype to be selected by default Closes #410

This commit is contained in:
Adubbz 2015-03-09 12:07:39 +11:00
parent bb7a5d11f5
commit ef4b82a338
7 changed files with 90 additions and 10 deletions

View File

@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright 2015, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.api.biome;
import net.minecraft.world.biome.BiomeGenBase;
import com.google.common.base.Optional;
public class BOPBiomes
{
public static Optional<BiomeGenBase> alps;
}

View File

@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright 2015, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.config;
import java.io.File;
import biomesoplenty.core.BiomesOPlenty;
import net.minecraftforge.common.config.Configuration;
public class MiscConfigurationHandler
{
public static Configuration config;
public static boolean useBoPWorldTypeDefault;
public static void init(File configFile)
{
config = new Configuration(configFile);
try
{
config.load();
//TODO: Make this default to true once all biomes have been implemented
useBoPWorldTypeDefault = config.getBoolean("Default to BoP World Type", "GUI Settings", false, "Use the Biomes O' Plenty World Type by default when selecting a world.");
}
catch (Exception e)
{
BiomesOPlenty.logger.error("Biomes O' Plenty has encountered a problem loading misc.cfg", e);
}
finally
{
if (config.hasChanged()) config.save();
}
}
}

View File

@ -11,19 +11,33 @@ package biomesoplenty.common.handler;
import java.util.ArrayList;
import java.util.List;
import biomesoplenty.common.init.ModBiomes;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.world.WorldType;
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import biomesoplenty.common.config.MiscConfigurationHandler;
import biomesoplenty.common.init.ModBiomes;
public class DrawScreenEventHandler
public class GuiEventHandler
{
public static int blockCount = 0;
@SubscribeEvent
public void onPreInitCreateWorld(InitGuiEvent.Pre event)
{
GuiScreen screenGui = event.gui;
if (MiscConfigurationHandler.useBoPWorldTypeDefault && screenGui instanceof GuiCreateWorld)
{
GuiCreateWorld createWorldGui = (GuiCreateWorld)screenGui;
createWorldGui.selectedIndex = ModBiomes.worldTypeBOP.getWorldTypeID();
}
}
@SubscribeEvent
public void onDrawScreen(DrawScreenEvent.Post event)
{
@ -31,7 +45,7 @@ public class DrawScreenEventHandler
if (screenGui instanceof GuiCreateWorld)
{
GuiCreateWorld createWorldGui = (GuiCreateWorld) screenGui;
GuiCreateWorld createWorldGui = (GuiCreateWorld)screenGui;
GuiButton mapTypeButton = createWorldGui.btnMapType;
int worldTypeIndex = createWorldGui.selectedIndex;

View File

@ -34,7 +34,7 @@ import biomesoplenty.common.block.BlockCoral;
import biomesoplenty.common.block.BlockGem;
import biomesoplenty.common.block.BlockGemOre;
import biomesoplenty.common.block.BlockHive;
import biomesoplenty.common.handler.DrawScreenEventHandler;
import biomesoplenty.common.handler.GuiEventHandler;
import biomesoplenty.common.item.ItemBlockWithVariants;
import biomesoplenty.common.util.block.BlockStateUtils;
import biomesoplenty.core.BiomesOPlenty;
@ -79,7 +79,7 @@ public class ModBlocks
ModelBakery.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + stateName);
BiomesOPlenty.proxy.registerBlockForMeshing(block, block.getMetaFromState(state), stateName);
DrawScreenEventHandler.blockCount++;
GuiEventHandler.blockCount++;
}
}
else
@ -89,7 +89,7 @@ public class ModBlocks
ModelBakery.addVariantName(Item.getItemFromBlock(block), BiomesOPlenty.MOD_ID + ":" + name);
BiomesOPlenty.proxy.registerBlockForMeshing(block, 0, name);
DrawScreenEventHandler.blockCount++;
GuiEventHandler.blockCount++;
}
return block;

View File

@ -11,12 +11,13 @@ package biomesoplenty.common.init;
import java.io.File;
import biomesoplenty.common.config.BiomeConfigurationHandler;
import biomesoplenty.common.config.MiscConfigurationHandler;
public class ModConfiguration
{
public static void init(File configDirectory)
{
MiscConfigurationHandler.init(new File(configDirectory, "misc.cfg"));
}
public static void initEnd(File configDirectory)

View File

@ -9,7 +9,7 @@
package biomesoplenty.common.init;
import net.minecraftforge.common.MinecraftForge;
import biomesoplenty.common.handler.DrawScreenEventHandler;
import biomesoplenty.common.handler.GuiEventHandler;
import biomesoplenty.common.handler.decoration.DecorateBiomeEventHandler;
public class ModHandlers
@ -17,6 +17,6 @@ public class ModHandlers
public static void init()
{
MinecraftForge.TERRAIN_GEN_BUS.register(new DecorateBiomeEventHandler());
MinecraftForge.EVENT_BUS.register(new DrawScreenEventHandler());
MinecraftForge.EVENT_BUS.register(new GuiEventHandler());
}
}

View File

@ -10,6 +10,9 @@ package biomesoplenty.core;
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
@ -35,6 +38,8 @@ public class BiomesOPlenty
@SidedProxy(clientSide = "biomesoplenty.core.ClientProxy", serverSide = "biomesoplenty.core.CommonProxy")
public static CommonProxy proxy;
public static Logger logger = LogManager.getLogger(MOD_ID);
private File configDirectory;
@EventHandler