Skip to content

Commit 8207d31

Browse files
authored
Merge pull request #24 from BuildTheEarth/earth_gui
Earth gui
2 parents c54210a + 9f3a0b7 commit 8207d31

File tree

12 files changed

+1441
-851
lines changed

12 files changed

+1441
-851
lines changed

src/main/java/net/buildtheearth/terraplusplus/BTEWorldType.java

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/main/java/net/buildtheearth/terraplusplus/EarthWorldType.java

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import io.github.opencubicchunks.cubicchunks.api.util.IntRange;
44
import io.github.opencubicchunks.cubicchunks.api.world.ICubicWorldType;
55
import io.github.opencubicchunks.cubicchunks.api.worldgen.ICubeGenerator;
6-
import net.buildtheearth.terraplusplus.control.EarthGui;
6+
import net.buildtheearth.terraplusplus.control.PresetEarthGui;
77
import net.buildtheearth.terraplusplus.generator.EarthGenerator;
88
import net.buildtheearth.terraplusplus.generator.EarthGeneratorSettings;
99
import net.minecraft.client.Minecraft;
@@ -17,53 +17,54 @@
1717
import net.minecraftforge.fml.relauncher.SideOnly;
1818

1919
public class EarthWorldType extends WorldType implements ICubicWorldType {
20-
21-
public static EarthWorldType create() {
22-
return new EarthWorldType();
23-
}
2420

25-
public EarthWorldType() {
26-
super("EarthCubic");
27-
}
21+
public static EarthWorldType create() {
22+
return new EarthWorldType();
23+
}
2824

29-
@Override
30-
public ICubeGenerator createCubeGenerator(World world) {
31-
return new EarthGenerator(world);
32-
}
25+
public EarthWorldType() {
26+
super("EarthCubic");
27+
}
3328

34-
@Override
35-
public BiomeProvider getBiomeProvider(World world) {
36-
return EarthGeneratorSettings.parse(world.getWorldInfo().getGeneratorOptions()).biomeProvider();
37-
}
29+
@Override
30+
public ICubeGenerator createCubeGenerator(World world) {
31+
return new EarthGenerator(world);
32+
}
3833

39-
@Override
40-
public IntRange calculateGenerationHeightRange(WorldServer world) {
41-
return new IntRange(-12000, 9000);
42-
}
34+
@Override
35+
public BiomeProvider getBiomeProvider(World world) {
36+
return EarthGeneratorSettings.parse(world.getWorldInfo().getGeneratorOptions()).biomeProvider();
37+
}
4338

44-
@Override
45-
public boolean hasCubicGeneratorForWorld(World w) {
46-
return w.provider instanceof WorldProviderSurface; // an even more general way to check if it's overworld (need custom providers)
47-
}
39+
@Override
40+
public IntRange calculateGenerationHeightRange(WorldServer world) {
41+
return new IntRange(-12000, 9000);
42+
}
4843

49-
@Override
50-
public boolean isCustomizable() {
51-
return true;
52-
}
44+
@Override
45+
public boolean hasCubicGeneratorForWorld(World w) {
46+
return w.provider instanceof WorldProviderSurface; // an even more general way to check if it's overworld (need custom providers)
47+
}
5348

54-
@Override
55-
public float getCloudHeight() {
56-
return 5000;
57-
}
49+
@Override
50+
public boolean isCustomizable() {
51+
return true;
52+
}
5853

59-
@Override
60-
public double voidFadeMagnitude() {
61-
return 0;
62-
}
54+
@Override
55+
public float getCloudHeight() {
56+
return 5000;
57+
}
6358

64-
@Override
65-
@SideOnly(Side.CLIENT)
66-
public void onCustomizeButton(Minecraft mc, GuiCreateWorld guiCreateWorld) {
67-
mc.displayGuiScreen(new EarthGui(guiCreateWorld, mc));
68-
}
59+
@Override
60+
public double voidFadeMagnitude() {
61+
return 0;
62+
}
63+
64+
@Override
65+
@SideOnly(Side.CLIENT)
66+
public void onCustomizeButton(Minecraft mc, GuiCreateWorld guiCreateWorld) {
67+
String sanitized = EarthGeneratorSettings.parse(guiCreateWorld.chunkProviderSettingsJson).toString();
68+
mc.displayGuiScreen(new PresetEarthGui(guiCreateWorld, sanitized, s -> guiCreateWorld.chunkProviderSettingsJson = s));
69+
}
6970
}
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package net.buildtheearth.terraplusplus;
22

3+
import org.apache.logging.log4j.Level;
4+
import org.apache.logging.log4j.Logger;
5+
import org.apache.logging.log4j.simple.SimpleLogger;
6+
import org.apache.logging.log4j.util.PropertiesUtil;
7+
38
import io.github.opencubicchunks.cubicchunks.core.CubicChunks;
9+
import net.buildtheearth.terraplusplus.control.AdvancedEarthGui;
10+
import net.buildtheearth.terraplusplus.control.PresetEarthGui;
411
import net.buildtheearth.terraplusplus.control.TerraCommand;
512
import net.buildtheearth.terraplusplus.control.TerraTeleport;
613
import net.buildtheearth.terraplusplus.provider.GenerationEventDenier;
@@ -18,17 +25,13 @@
1825
import net.minecraftforge.fml.relauncher.Side;
1926
import net.minecraftforge.server.permission.DefaultPermissionLevel;
2027
import net.minecraftforge.server.permission.PermissionAPI;
21-
import org.apache.logging.log4j.Level;
22-
import org.apache.logging.log4j.Logger;
23-
import org.apache.logging.log4j.simple.SimpleLogger;
24-
import org.apache.logging.log4j.util.PropertiesUtil;
2528

2629
@Mod(modid = TerraConstants.MODID,
27-
dependencies = "required-after:cubicchunks; required-after:cubicgen",
28-
acceptableRemoteVersions = "*",
29-
useMetadata = true)
30+
dependencies = "required-after:cubicchunks; required-after:cubicgen",
31+
acceptableRemoteVersions = "*",
32+
useMetadata = true)
3033
public class TerraMod {
31-
public static Logger LOGGER = new SimpleLogger("[terra++ bootstrap]", Level.INFO, true, false, true, false, "[yyyy/MM/dd HH:mm:ss:SSS]", null, new PropertiesUtil("log4j2.simplelog.properties"), System.out);
34+
public static Logger LOGGER = new SimpleLogger("[terra++ bootstrap]", Level.INFO, true, false, true, false, "[yyyy/MM/dd HH:mm:ss:SSS]", null, new PropertiesUtil("log4j2.simplelog.properties"), System.out);
3235

3336
@EventHandler
3437
public void construction(FMLConstructionEvent event) {
@@ -40,38 +43,34 @@ public void construction(FMLConstructionEvent event) {
4043
TerraConstants.CC_VERSION = Loader.instance().getIndexedModList().get(CubicChunks.MODID).getVersion();
4144
}
4245

43-
@EventHandler
44-
public void preInit(FMLPreInitializationEvent event) {
45-
LOGGER = event.getModLog();
46-
EarthWorldType.create();
46+
@EventHandler
47+
public void preInit(FMLPreInitializationEvent event) {
48+
LOGGER = event.getModLog();
49+
EarthWorldType.create();
50+
}
4751

48-
// This is just a handy shortcut when creating new BTE worlds on the client not needed on the server
49-
// It is critical that this happens after the EarthWorldType is registered
50-
if (Side.CLIENT == event.getSide()) {
51-
BTEWorldType.create();
52-
}
53-
}
54-
55-
@EventHandler
56-
public void init(FMLInitializationEvent event) {
57-
if (TerraConfig.threeWater) {
58-
MinecraftForge.EVENT_BUS.register(WaterDenier.class);
59-
}
60-
if (Side.CLIENT == event.getSide()) {
61-
MinecraftForge.EVENT_BUS.register(BTEWorldType.class);
62-
}
63-
MinecraftForge.TERRAIN_GEN_BUS.register(GenerationEventDenier.class);
52+
@EventHandler
53+
public void init(FMLInitializationEvent event) {
54+
if (TerraConfig.threeWater) {
55+
MinecraftForge.EVENT_BUS.register(WaterDenier.class);
56+
}
57+
MinecraftForge.TERRAIN_GEN_BUS.register(GenerationEventDenier.class);
6458

65-
PermissionAPI.registerNode(TerraConstants.othersCommandNode, DefaultPermissionLevel.OP, "Allows a player to control another player in terra commands");
66-
}
59+
PermissionAPI.registerNode(TerraConstants.othersCommandNode, DefaultPermissionLevel.OP, "Allows a player to control another player in terra commands");
60+
}
6761

68-
@EventHandler
69-
public void postInit(FMLPostInitializationEvent event) {
70-
}
62+
@EventHandler
63+
public void postInit(FMLPostInitializationEvent event) {
64+
if(event.getSide() == Side.CLIENT) {
65+
// Force the static resources to load here so the GUI doesn't freeze for 5s when first opened
66+
AdvancedEarthGui.DIRECTIONS_TEXTURE.hashCode();
67+
PresetEarthGui.DEFAULT_PRESETS.hashCode();
68+
}
69+
}
7170

72-
@EventHandler
73-
public void serverLoad(FMLServerStartingEvent event) {
74-
event.registerServerCommand(new TerraTeleport());
75-
event.registerServerCommand(new TerraCommand());
76-
}
71+
@EventHandler
72+
public void serverLoad(FMLServerStartingEvent event) {
73+
event.registerServerCommand(new TerraTeleport());
74+
event.registerServerCommand(new TerraCommand());
75+
}
7776
}

0 commit comments

Comments
 (0)