ForgePatch/patches/minecraft/net/minecraft/world/WorldType.java.patch

86 lines
2.7 KiB
Diff

--- a/net/minecraft/world/WorldType.java
+++ b/net/minecraft/world/WorldType.java
@@ -22,6 +22,10 @@
private boolean field_151361_l;
private boolean field_205395_p;
+ public WorldType(String name) {
+ this(getNextID(), name);
+ }
+
private WorldType(int p_i1959_1_, String p_i1959_2_) {
this(p_i1959_1_, p_i1959_2_, p_i1959_2_, 0);
}
@@ -31,6 +35,7 @@
}
private WorldType(int p_i49778_1_, String p_i49778_2_, String p_i49778_3_, int p_i49778_4_) {
+ if (p_i49778_2_.length() > 16 && field_180272_g != null) throw new IllegalArgumentException("World type names must not be longer then 16: " + p_i49778_2_);
this.field_77133_f = p_i49778_2_;
this.field_211890_l = p_i49778_3_;
this.field_77134_g = p_i49778_4_;
@@ -39,6 +44,17 @@
field_77139_a[p_i49778_1_] = this;
}
+ private static int getNextID() {
+ for (int x = 0; x < field_77139_a.length; x++) {
+ if (field_77139_a[x] == null) {
+ return x;
+ }
+ }
+ int old = field_77139_a.length;
+ field_77139_a = java.util.Arrays.copyOf(field_77139_a, old + 16);
+ return old;
+ }
+
public String func_211888_a() {
return this.field_77133_f;
}
@@ -117,4 +133,45 @@
this.field_151361_l = true;
return this;
}
+
+ /**
+ * Called when 'Create New World' button is pressed before starting game
+ */
+ public void onGUICreateWorldPress() { }
+
+ /**
+ * Called when the 'Customize' button is pressed on world creation GUI
+ * @param mc The Minecraft instance
+ * @param gui the createworld GUI
+ */
+ @OnlyIn(Dist.CLIENT)
+ public void onCustomizeButton(net.minecraft.client.Minecraft mc, net.minecraft.client.gui.GuiCreateWorld gui) {
+ if (this == WorldType.field_77138_c)
+ mc.func_147108_a(new net.minecraft.client.gui.GuiCreateFlatWorld(gui, gui.field_146334_a));
+ else if (this == WorldType.field_180271_f)
+ mc.func_147108_a(new net.minecraft.client.gui.GuiCreateBuffetWorld(gui, gui.field_146334_a));
+ }
+
+ public boolean handleSlimeSpawnReduction(java.util.Random random, World world) {
+ return this == field_77138_c ? random.nextInt(4) != 1 : false;
+ }
+
+ public double getHorizon(World world) {
+ return this == field_77138_c ? 0.0D : 63.0D;
+ }
+
+ /**
+ * Get the height to render the clouds for this world type
+ * @return The height to render clouds at
+ */
+ public float getCloudHeight() {
+ return 128.0F;
+ }
+
+ @SuppressWarnings("deprecation")
+ public net.minecraft.world.gen.IChunkGenerator<?> createChunkGenerator(World world) {
+ return world.field_73011_w.func_186060_c();
+ }
+
+
}