Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External generator settings (new implementation) #10

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,7 +32,6 @@
import io.github.opencubicchunks.cubicchunks.cubicgen.common.biome.replacer.SwampWaterWithLilypadReplacer;
import io.github.opencubicchunks.cubicchunks.cubicgen.common.biome.replacer.TaigaSurfaceReplacer;
import io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.CustomCubicWorldType;
import io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.CustomGeneratorSettings;
import io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.populator.DefaultDecorator;
import io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.populator.DesertDecorator;
import io.github.opencubicchunks.cubicchunks.cubicgen.customcubic.populator.ForestDecorator;
Expand Down Expand Up @@ -63,9 +62,7 @@
import net.minecraft.world.biome.BiomeStoneBeach;
import net.minecraft.world.biome.BiomeSwamp;
import net.minecraft.world.biome.BiomeTaiga;
import net.minecraftforge.common.util.ModFixs;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
Expand Down Expand Up @@ -102,17 +99,13 @@ public void preInit(FMLPreInitializationEvent e) {
FlatCubicWorldType.create();
CustomCubicWorldType.create();
DebugWorldType.create();


ModFixs fixes = FMLCommonHandler.instance().getDataFixer().init(MODID, FIXER_VERSION);
CustomGeneratorSettings.registerDataFixers(fixes);
}

@Mod.EventHandler
public void preInit(FMLPostInitializationEvent e) {
CubicBiome.postInit();
}

@SubscribeEvent
public static void registerRegistries(RegistryEvent.NewRegistry evt) {
CubicBiome.init();
Expand Down
Expand Up @@ -33,9 +33,7 @@
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.init.Biomes;
import net.minecraft.world.DimensionType;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldProviderSurface;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldType;
Expand All @@ -56,6 +54,10 @@
@MethodsReturnNonnullByDefault
public class CustomCubicWorldType extends WorldType implements ICubicWorldType {

// This string is not empty when and only when someone used a CustomCubicGUI
// and press a Done button both in this CustomCubicGUI and in a WorldCreationGUI
public static String pendingCustomCubicSettingsJsonString = "";

private CustomCubicWorldType() {
super("CustomCubic");
}
Expand All @@ -65,8 +67,7 @@ public static CustomCubicWorldType create() {
}

@Override public IntRange calculateGenerationHeightRange(WorldServer world) {
String string = world.getWorldInfo().getGeneratorOptions();
CustomGeneratorSettings opts = CustomGeneratorSettings.fromJson(string);
CustomGeneratorSettings opts = CustomGeneratorSettings.load(world);
// TODO: better handling of min height
return new IntRange(0, (int) opts.actualHeight);
}
Expand Down Expand Up @@ -94,6 +95,12 @@ public ICubeGenerator createCubeGenerator(World world) {
public boolean isCustomizable() {
return true;
}

@Override
public void onGUICreateWorldPress() {
pendingCustomCubicSettingsJsonString = CustomCubicGui.settingsJsonString;
CustomCubicGui.settingsJsonString = "";
}

@SideOnly(Side.CLIENT)
public void onCustomizeButton(Minecraft mc, GuiCreateWorld guiCreateWorld) {
Expand Down