| 1 | package net.minecraft.client.gui;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import java.util.Random;
|
| 5 | import net.minecraft.client.resources.I18n;
|
| 6 | import net.minecraft.util.ChatAllowedCharacters;
|
| 7 | import net.minecraft.world.WorldSettings;
|
| 8 | import net.minecraft.world.WorldType;
|
| 9 | import net.minecraft.world.storage.ISaveFormat;
|
| 10 | import net.minecraft.world.storage.WorldInfo;
|
| 11 | import org.apache.commons.lang3.StringUtils;
|
| 12 | import org.lwjgl.input.Keyboard;
|
| 13 |
|
| 14 | public class GuiCreateWorld extends GuiScreen
|
| 15 | {
|
| 16 | private GuiScreen parentScreen;
|
| 17 | private GuiTextField worldNameField;
|
| 18 | private GuiTextField worldSeedField;
|
| 19 | private String saveDirName;
|
| 20 | private String gameMode = "survival";
|
| 21 |
|
| 22 | /**
|
| 23 | * Used to save away the game mode when the current "debug" world type is chosen (forcing it to spectator mode)
|
| 24 | */
|
| 25 | private String savedGameMode;
|
| 26 | private boolean generateStructuresEnabled = true;
|
| 27 |
|
| 28 | /** If cheats are allowed */
|
| 29 | private boolean allowCheats;
|
| 30 |
|
| 31 | /**
|
| 32 | * User explicitly clicked "Allow Cheats" at some point
|
| 33 | * Prevents value changes due to changing game mode
|
| 34 | */
|
| 35 | private boolean allowCheatsWasSetByUser;
|
| 36 | private boolean bonusChestEnabled;
|
| 37 |
|
| 38 | /** Set to true when "hardcore" is the currently-selected gamemode */
|
| 39 | private boolean hardCoreMode;
|
| 40 | private boolean alreadyGenerated;
|
| 41 | private boolean inMoreWorldOptionsDisplay;
|
| 42 | private GuiButton btnGameMode;
|
| 43 | private GuiButton btnMoreOptions;
|
| 44 | private GuiButton btnMapFeatures;
|
| 45 | private GuiButton btnBonusItems;
|
| 46 | private GuiButton btnMapType;
|
| 47 | private GuiButton btnAllowCommands;
|
| 48 | private GuiButton btnCustomizeType;
|
| 49 | private String gameModeDesc1;
|
| 50 | private String gameModeDesc2;
|
| 51 | private String worldSeed;
|
| 52 | private String worldName;
|
| 53 | private int selectedIndex;
|
| 54 | public String chunkProviderSettingsJson = "";
|
| 55 |
|
| 56 | /** These filenames are known to be restricted on one or more OS's. */
|
| 57 | private static final String[] disallowedFilenames = new String[] {"CON", "COM", "PRN", "AUX", "CLOCK$", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"};
|
| 58 |
|
| 59 | public GuiCreateWorld(GuiScreen p_i46320_1_)
|
| 60 | {
|
| 61 | this.parentScreen = p_i46320_1_;
|
| 62 | this.worldSeed = "";
|
| 63 | this.worldName = I18n.format("selectWorld.newWorld", new Object[0]);
|
| 64 | }
|
| 65 |
|
| 66 | /**
|
| 67 | * Called from the main game loop to update the screen.
|
| 68 | */
|
| 69 | public void updateScreen()
|
| 70 | {
|
| 71 | this.worldNameField.updateCursorCounter();
|
| 72 | this.worldSeedField.updateCursorCounter();
|
| 73 | }
|
| 74 |
|
| 75 | /**
|
| 76 | * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
| 77 | * window resizes, the buttonList is cleared beforehand.
|
| 78 | */
|
| 79 | public void initGui()
|
| 80 | {
|
| 81 | Keyboard.enableRepeatEvents(true);
|
| 82 | this.buttonList.clear();
|
| 83 | this.buttonList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("selectWorld.create", new Object[0])));
|
| 84 | this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0])));
|
| 85 | this.buttonList.add(this.btnGameMode = new GuiButton(2, this.width / 2 - 75, 115, 150, 20, I18n.format("selectWorld.gameMode", new Object[0])));
|
| 86 | this.buttonList.add(this.btnMoreOptions = new GuiButton(3, this.width / 2 - 75, 187, 150, 20, I18n.format("selectWorld.moreWorldOptions", new Object[0])));
|
| 87 | this.buttonList.add(this.btnMapFeatures = new GuiButton(4, this.width / 2 - 155, 100, 150, 20, I18n.format("selectWorld.mapFeatures", new Object[0])));
|
| 88 | this.btnMapFeatures.visible = false;
|
| 89 | this.buttonList.add(this.btnBonusItems = new GuiButton(7, this.width / 2 + 5, 151, 150, 20, I18n.format("selectWorld.bonusItems", new Object[0])));
|
| 90 | this.btnBonusItems.visible = false;
|
| 91 | this.buttonList.add(this.btnMapType = new GuiButton(5, this.width / 2 + 5, 100, 150, 20, I18n.format("selectWorld.mapType", new Object[0])));
|
| 92 | this.btnMapType.visible = false;
|
| 93 | this.buttonList.add(this.btnAllowCommands = new GuiButton(6, this.width / 2 - 155, 151, 150, 20, I18n.format("selectWorld.allowCommands", new Object[0])));
|
| 94 | this.btnAllowCommands.visible = false;
|
| 95 | this.buttonList.add(this.btnCustomizeType = new GuiButton(8, this.width / 2 + 5, 120, 150, 20, I18n.format("selectWorld.customizeType", new Object[0])));
|
| 96 | this.btnCustomizeType.visible = false;
|
| 97 | this.worldNameField = new GuiTextField(9, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
|
| 98 | this.worldNameField.setFocused(true);
|
| 99 | this.worldNameField.setText(this.worldName);
|
| 100 | this.worldSeedField = new GuiTextField(10, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
|
| 101 | this.worldSeedField.setText(this.worldSeed);
|
| 102 | this.showMoreWorldOptions(this.inMoreWorldOptionsDisplay);
|
| 103 | this.calcSaveDirName();
|
| 104 | this.updateDisplayState();
|
| 105 | }
|
| 106 |
|
| 107 | /**
|
| 108 | * Determine a save-directory name from the world name
|
| 109 | */
|
| 110 | private void calcSaveDirName()
|
| 111 | {
|
| 112 | this.saveDirName = this.worldNameField.getText().trim();
|
| 113 |
|
| 114 | for (char c0 : ChatAllowedCharacters.allowedCharactersArray)
|
| 115 | {
|
| 116 | this.saveDirName = this.saveDirName.replace(c0, '_');
|
| 117 | }
|
| 118 |
|
| 119 | if (StringUtils.isEmpty(this.saveDirName))
|
| 120 | {
|
| 121 | this.saveDirName = "World";
|
| 122 | }
|
| 123 |
|
| 124 | this.saveDirName = getUncollidingSaveDirName(this.mc.getSaveLoader(), this.saveDirName);
|
| 125 | }
|
| 126 |
|
| 127 | /**
|
| 128 | * Sets displayed GUI elements according to the current settings state
|
| 129 | */
|
| 130 | private void updateDisplayState()
|
| 131 | {
|
| 132 | this.btnGameMode.displayString = I18n.format("selectWorld.gameMode", new Object[0]) + ": " + I18n.format("selectWorld.gameMode." + this.gameMode, new Object[0]);
|
| 133 | this.gameModeDesc1 = I18n.format("selectWorld.gameMode." + this.gameMode + ".line1", new Object[0]);
|
| 134 | this.gameModeDesc2 = I18n.format("selectWorld.gameMode." + this.gameMode + ".line2", new Object[0]);
|
| 135 | this.btnMapFeatures.displayString = I18n.format("selectWorld.mapFeatures", new Object[0]) + " ";
|
| 136 |
|
| 137 | if (this.generateStructuresEnabled)
|
| 138 | {
|
| 139 | this.btnMapFeatures.displayString = this.btnMapFeatures.displayString + I18n.format("options.on", new Object[0]);
|
| 140 | }
|
| 141 | else
|
| 142 | {
|
| 143 | this.btnMapFeatures.displayString = this.btnMapFeatures.displayString + I18n.format("options.off", new Object[0]);
|
| 144 | }
|
| 145 |
|
| 146 | this.btnBonusItems.displayString = I18n.format("selectWorld.bonusItems", new Object[0]) + " ";
|
| 147 |
|
| 148 | if (this.bonusChestEnabled && !this.hardCoreMode)
|
| 149 | {
|
| 150 | this.btnBonusItems.displayString = this.btnBonusItems.displayString + I18n.format("options.on", new Object[0]);
|
| 151 | }
|
| 152 | else
|
| 153 | {
|
| 154 | this.btnBonusItems.displayString = this.btnBonusItems.displayString + I18n.format("options.off", new Object[0]);
|
| 155 | }
|
| 156 |
|
| 157 | this.btnMapType.displayString = I18n.format("selectWorld.mapType", new Object[0]) + " " + I18n.format(WorldType.worldTypes[this.selectedIndex].getTranslateName(), new Object[0]);
|
| 158 | this.btnAllowCommands.displayString = I18n.format("selectWorld.allowCommands", new Object[0]) + " ";
|
| 159 |
|
| 160 | if (this.allowCheats && !this.hardCoreMode)
|
| 161 | {
|
| 162 | this.btnAllowCommands.displayString = this.btnAllowCommands.displayString + I18n.format("options.on", new Object[0]);
|
| 163 | }
|
| 164 | else
|
| 165 | {
|
| 166 | this.btnAllowCommands.displayString = this.btnAllowCommands.displayString + I18n.format("options.off", new Object[0]);
|
| 167 | }
|
| 168 | }
|
| 169 |
|
| 170 | /**
|
| 171 | * Ensures that a proposed directory name doesn't collide with existing names.
|
| 172 | * Returns the name, possibly modified to avoid collisions.
|
| 173 | *
|
| 174 | * @param saveLoader used to check against existing names
|
| 175 | * @param name the name to check, and possibly adjust (via the method's return)
|
| 176 | */
|
| 177 | public static String getUncollidingSaveDirName(ISaveFormat saveLoader, String name)
|
| 178 | {
|
| 179 | name = name.replaceAll("[\\./\"]", "_");
|
| 180 |
|
| 181 | for (String s : disallowedFilenames)
|
| 182 | {
|
| 183 | if (name.equalsIgnoreCase(s))
|
| 184 | {
|
| 185 | name = "_" + name + "_";
|
| 186 | }
|
| 187 | }
|
| 188 |
|
| 189 | while (saveLoader.getWorldInfo(name) != null)
|
| 190 | {
|
| 191 | name = name + "-";
|
| 192 | }
|
| 193 |
|
| 194 | return name;
|
| 195 | }
|
| 196 |
|
| 197 | /**
|
| 198 | * Called when the screen is unloaded. Used to disable keyboard repeat events
|
| 199 | */
|
| 200 | public void onGuiClosed()
|
| 201 | {
|
| 202 | Keyboard.enableRepeatEvents(false);
|
| 203 | }
|
| 204 |
|
| 205 | /**
|
| 206 | * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
| 207 | */
|
| 208 | protected void actionPerformed(GuiButton button) throws IOException
|
| 209 | {
|
| 210 | if (button.enabled)
|
| 211 | {
|
| 212 | if (button.id == 1)
|
| 213 | {
|
| 214 | this.mc.displayGuiScreen(this.parentScreen);
|
| 215 | }
|
| 216 | else if (button.id == 0)
|
| 217 | {
|
| 218 | this.mc.displayGuiScreen((GuiScreen)null);
|
| 219 |
|
| 220 | if (this.alreadyGenerated)
|
| 221 | {
|
| 222 | return;
|
| 223 | }
|
| 224 |
|
| 225 | this.alreadyGenerated = true;
|
| 226 | long i = (new Random()).nextLong();
|
| 227 | String s = this.worldSeedField.getText();
|
| 228 |
|
| 229 | if (!StringUtils.isEmpty(s))
|
| 230 | {
|
| 231 | try
|
| 232 | {
|
| 233 | long j = Long.parseLong(s);
|
| 234 |
|
| 235 | if (j != 0L)
|
| 236 | {
|
| 237 | i = j;
|
| 238 | }
|
| 239 | }
|
| 240 | catch (NumberFormatException var7)
|
| 241 | {
|
| 242 | i = (long)s.hashCode();
|
| 243 | }
|
| 244 | }
|
| 245 |
|
| 246 | WorldSettings.GameType worldsettings$gametype = WorldSettings.GameType.getByName(this.gameMode);
|
| 247 | WorldSettings worldsettings = new WorldSettings(i, worldsettings$gametype, this.generateStructuresEnabled, this.hardCoreMode, WorldType.worldTypes[this.selectedIndex]);
|
| 248 | worldsettings.setWorldName(this.chunkProviderSettingsJson);
|
| 249 |
|
| 250 | if (this.bonusChestEnabled && !this.hardCoreMode)
|
| 251 | {
|
| 252 | worldsettings.enableBonusChest();
|
| 253 | }
|
| 254 |
|
| 255 | if (this.allowCheats && !this.hardCoreMode)
|
| 256 | {
|
| 257 | worldsettings.enableCommands();
|
| 258 | }
|
| 259 |
|
| 260 | this.mc.launchIntegratedServer(this.saveDirName, this.worldNameField.getText().trim(), worldsettings);
|
| 261 | }
|
| 262 | else if (button.id == 3)
|
| 263 | {
|
| 264 | this.toggleMoreWorldOptions();
|
| 265 | }
|
| 266 | else if (button.id == 2)
|
| 267 | {
|
| 268 | if (this.gameMode.equals("survival"))
|
| 269 | {
|
| 270 | if (!this.allowCheatsWasSetByUser)
|
| 271 | {
|
| 272 | this.allowCheats = false;
|
| 273 | }
|
| 274 |
|
| 275 | this.hardCoreMode = false;
|
| 276 | this.gameMode = "hardcore";
|
| 277 | this.hardCoreMode = true;
|
| 278 | this.btnAllowCommands.enabled = false;
|
| 279 | this.btnBonusItems.enabled = false;
|
| 280 | this.updateDisplayState();
|
| 281 | }
|
| 282 | else if (this.gameMode.equals("hardcore"))
|
| 283 | {
|
| 284 | if (!this.allowCheatsWasSetByUser)
|
| 285 | {
|
| 286 | this.allowCheats = true;
|
| 287 | }
|
| 288 |
|
| 289 | this.hardCoreMode = false;
|
| 290 | this.gameMode = "creative";
|
| 291 | this.updateDisplayState();
|
| 292 | this.hardCoreMode = false;
|
| 293 | this.btnAllowCommands.enabled = true;
|
| 294 | this.btnBonusItems.enabled = true;
|
| 295 | }
|
| 296 | else
|
| 297 | {
|
| 298 | if (!this.allowCheatsWasSetByUser)
|
| 299 | {
|
| 300 | this.allowCheats = false;
|
| 301 | }
|
| 302 |
|
| 303 | this.gameMode = "survival";
|
| 304 | this.updateDisplayState();
|
| 305 | this.btnAllowCommands.enabled = true;
|
| 306 | this.btnBonusItems.enabled = true;
|
| 307 | this.hardCoreMode = false;
|
| 308 | }
|
| 309 |
|
| 310 | this.updateDisplayState();
|
| 311 | }
|
| 312 | else if (button.id == 4)
|
| 313 | {
|
| 314 | this.generateStructuresEnabled = !this.generateStructuresEnabled;
|
| 315 | this.updateDisplayState();
|
| 316 | }
|
| 317 | else if (button.id == 7)
|
| 318 | {
|
| 319 | this.bonusChestEnabled = !this.bonusChestEnabled;
|
| 320 | this.updateDisplayState();
|
| 321 | }
|
| 322 | else if (button.id == 5)
|
| 323 | {
|
| 324 | ++this.selectedIndex;
|
| 325 |
|
| 326 | if (this.selectedIndex >= WorldType.worldTypes.length)
|
| 327 | {
|
| 328 | this.selectedIndex = 0;
|
| 329 | }
|
| 330 |
|
| 331 | while (!this.canSelectCurWorldType())
|
| 332 | {
|
| 333 | ++this.selectedIndex;
|
| 334 |
|
| 335 | if (this.selectedIndex >= WorldType.worldTypes.length)
|
| 336 | {
|
| 337 | this.selectedIndex = 0;
|
| 338 | }
|
| 339 | }
|
| 340 |
|
| 341 | this.chunkProviderSettingsJson = "";
|
| 342 | this.updateDisplayState();
|
| 343 | this.showMoreWorldOptions(this.inMoreWorldOptionsDisplay);
|
| 344 | }
|
| 345 | else if (button.id == 6)
|
| 346 | {
|
| 347 | this.allowCheatsWasSetByUser = true;
|
| 348 | this.allowCheats = !this.allowCheats;
|
| 349 | this.updateDisplayState();
|
| 350 | }
|
| 351 | else if (button.id == 8)
|
| 352 | {
|
| 353 | if (WorldType.worldTypes[this.selectedIndex] == WorldType.FLAT)
|
| 354 | {
|
| 355 | this.mc.displayGuiScreen(new GuiCreateFlatWorld(this, this.chunkProviderSettingsJson));
|
| 356 | }
|
| 357 | else
|
| 358 | {
|
| 359 | this.mc.displayGuiScreen(new GuiCustomizeWorldScreen(this, this.chunkProviderSettingsJson));
|
| 360 | }
|
| 361 | }
|
| 362 | }
|
| 363 | }
|
| 364 |
|
| 365 | /**
|
| 366 | * Returns whether the currently-selected world type is actually acceptable for selection
|
| 367 | * Used to hide the "debug" world type unless the shift key is depressed.
|
| 368 | */
|
| 369 | private boolean canSelectCurWorldType()
|
| 370 | {
|
| 371 | WorldType worldtype = WorldType.worldTypes[this.selectedIndex];
|
| 372 | return worldtype != null && worldtype.getCanBeCreated() ? (worldtype == WorldType.DEBUG_WORLD ? isShiftKeyDown() : true) : false;
|
| 373 | }
|
| 374 |
|
| 375 | /**
|
| 376 | * Toggles between initial world-creation display, and "more options" display.
|
| 377 | * Called when user clicks "More World Options..." or "Done" (same button, different labels depending on current
|
| 378 | * display).
|
| 379 | */
|
| 380 | private void toggleMoreWorldOptions()
|
| 381 | {
|
| 382 | this.showMoreWorldOptions(!this.inMoreWorldOptionsDisplay);
|
| 383 | }
|
| 384 |
|
| 385 | /**
|
| 386 | * Shows additional world-creation options if toggle is true, otherwise shows main world-creation elements
|
| 387 | */
|
| 388 | private void showMoreWorldOptions(boolean toggle)
|
| 389 | {
|
| 390 | this.inMoreWorldOptionsDisplay = toggle;
|
| 391 |
|
| 392 | if (WorldType.worldTypes[this.selectedIndex] == WorldType.DEBUG_WORLD)
|
| 393 | {
|
| 394 | this.btnGameMode.visible = !this.inMoreWorldOptionsDisplay;
|
| 395 | this.btnGameMode.enabled = false;
|
| 396 |
|
| 397 | if (this.savedGameMode == null)
|
| 398 | {
|
| 399 | this.savedGameMode = this.gameMode;
|
| 400 | }
|
| 401 |
|
| 402 | this.gameMode = "spectator";
|
| 403 | this.btnMapFeatures.visible = false;
|
| 404 | this.btnBonusItems.visible = false;
|
| 405 | this.btnMapType.visible = this.inMoreWorldOptionsDisplay;
|
| 406 | this.btnAllowCommands.visible = false;
|
| 407 | this.btnCustomizeType.visible = false;
|
| 408 | }
|
| 409 | else
|
| 410 | {
|
| 411 | this.btnGameMode.visible = !this.inMoreWorldOptionsDisplay;
|
| 412 | this.btnGameMode.enabled = true;
|
| 413 |
|
| 414 | if (this.savedGameMode != null)
|
| 415 | {
|
| 416 | this.gameMode = this.savedGameMode;
|
| 417 | this.savedGameMode = null;
|
| 418 | }
|
| 419 |
|
| 420 | this.btnMapFeatures.visible = this.inMoreWorldOptionsDisplay && WorldType.worldTypes[this.selectedIndex] != WorldType.CUSTOMIZED;
|
| 421 | this.btnBonusItems.visible = this.inMoreWorldOptionsDisplay;
|
| 422 | this.btnMapType.visible = this.inMoreWorldOptionsDisplay;
|
| 423 | this.btnAllowCommands.visible = this.inMoreWorldOptionsDisplay;
|
| 424 | this.btnCustomizeType.visible = this.inMoreWorldOptionsDisplay && (WorldType.worldTypes[this.selectedIndex] == WorldType.FLAT || WorldType.worldTypes[this.selectedIndex] == WorldType.CUSTOMIZED);
|
| 425 | }
|
| 426 |
|
| 427 | this.updateDisplayState();
|
| 428 |
|
| 429 | if (this.inMoreWorldOptionsDisplay)
|
| 430 | {
|
| 431 | this.btnMoreOptions.displayString = I18n.format("gui.done", new Object[0]);
|
| 432 | }
|
| 433 | else
|
| 434 | {
|
| 435 | this.btnMoreOptions.displayString = I18n.format("selectWorld.moreWorldOptions", new Object[0]);
|
| 436 | }
|
| 437 | }
|
| 438 |
|
| 439 | /**
|
| 440 | * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
|
| 441 | * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
|
| 442 | */
|
| 443 | protected void keyTyped(char typedChar, int keyCode) throws IOException
|
| 444 | {
|
| 445 | if (this.worldNameField.isFocused() && !this.inMoreWorldOptionsDisplay)
|
| 446 | {
|
| 447 | this.worldNameField.textboxKeyTyped(typedChar, keyCode);
|
| 448 | this.worldName = this.worldNameField.getText();
|
| 449 | }
|
| 450 | else if (this.worldSeedField.isFocused() && this.inMoreWorldOptionsDisplay)
|
| 451 | {
|
| 452 | this.worldSeedField.textboxKeyTyped(typedChar, keyCode);
|
| 453 | this.worldSeed = this.worldSeedField.getText();
|
| 454 | }
|
| 455 |
|
| 456 | if (keyCode == 28 || keyCode == 156)
|
| 457 | {
|
| 458 | this.actionPerformed((GuiButton)this.buttonList.get(0));
|
| 459 | }
|
| 460 |
|
| 461 | ((GuiButton)this.buttonList.get(0)).enabled = this.worldNameField.getText().length() > 0;
|
| 462 | this.calcSaveDirName();
|
| 463 | }
|
| 464 |
|
| 465 | /**
|
| 466 | * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
|
| 467 | */
|
| 468 | protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
|
| 469 | {
|
| 470 | super.mouseClicked(mouseX, mouseY, mouseButton);
|
| 471 |
|
| 472 | if (this.inMoreWorldOptionsDisplay)
|
| 473 | {
|
| 474 | this.worldSeedField.mouseClicked(mouseX, mouseY, mouseButton);
|
| 475 | }
|
| 476 | else
|
| 477 | {
|
| 478 | this.worldNameField.mouseClicked(mouseX, mouseY, mouseButton);
|
| 479 | }
|
| 480 | }
|
| 481 |
|
| 482 | /**
|
| 483 | * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
| 484 | */
|
| 485 | public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
| 486 | {
|
| 487 | this.drawDefaultBackground();
|
| 488 | this.drawCenteredString(this.fontRendererObj, I18n.format("selectWorld.create", new Object[0]), this.width / 2, 20, -1);
|
| 489 |
|
| 490 | if (this.inMoreWorldOptionsDisplay)
|
| 491 | {
|
| 492 | this.drawString(this.fontRendererObj, I18n.format("selectWorld.enterSeed", new Object[0]), this.width / 2 - 100, 47, -6250336);
|
| 493 | this.drawString(this.fontRendererObj, I18n.format("selectWorld.seedInfo", new Object[0]), this.width / 2 - 100, 85, -6250336);
|
| 494 |
|
| 495 | if (this.btnMapFeatures.visible)
|
| 496 | {
|
| 497 | this.drawString(this.fontRendererObj, I18n.format("selectWorld.mapFeatures.info", new Object[0]), this.width / 2 - 150, 122, -6250336);
|
| 498 | }
|
| 499 |
|
| 500 | if (this.btnAllowCommands.visible)
|
| 501 | {
|
| 502 | this.drawString(this.fontRendererObj, I18n.format("selectWorld.allowCommands.info", new Object[0]), this.width / 2 - 150, 172, -6250336);
|
| 503 | }
|
| 504 |
|
| 505 | this.worldSeedField.drawTextBox();
|
| 506 |
|
| 507 | if (WorldType.worldTypes[this.selectedIndex].showWorldInfoNotice())
|
| 508 | {
|
| 509 | this.fontRendererObj.drawSplitString(I18n.format(WorldType.worldTypes[this.selectedIndex].getTranslatedInfo(), new Object[0]), this.btnMapType.xPosition + 2, this.btnMapType.yPosition + 22, this.btnMapType.getButtonWidth(), 10526880);
|
| 510 | }
|
| 511 | }
|
| 512 | else
|
| 513 | {
|
| 514 | this.drawString(this.fontRendererObj, I18n.format("selectWorld.enterName", new Object[0]), this.width / 2 - 100, 47, -6250336);
|
| 515 | this.drawString(this.fontRendererObj, I18n.format("selectWorld.resultFolder", new Object[0]) + " " + this.saveDirName, this.width / 2 - 100, 85, -6250336);
|
| 516 | this.worldNameField.drawTextBox();
|
| 517 | this.drawString(this.fontRendererObj, this.gameModeDesc1, this.width / 2 - 100, 137, -6250336);
|
| 518 | this.drawString(this.fontRendererObj, this.gameModeDesc2, this.width / 2 - 100, 149, -6250336);
|
| 519 | }
|
| 520 |
|
| 521 | super.drawScreen(mouseX, mouseY, partialTicks);
|
| 522 | }
|
| 523 |
|
| 524 | /**
|
| 525 | * Set the initial values of a new world to create, from the values from an existing world.
|
| 526 | *
|
| 527 | * Called after construction when a user selects the "Recreate" button.
|
| 528 | *
|
| 529 | * @param original The world we're copying from
|
| 530 | */
|
| 531 | public void recreateFromExistingWorld(WorldInfo original)
|
| 532 | {
|
| 533 | this.worldName = I18n.format("selectWorld.newWorld.copyOf", new Object[] {original.getWorldName()});
|
| 534 | this.worldSeed = original.getSeed() + "";
|
| 535 | this.selectedIndex = original.getTerrainType().getWorldTypeID();
|
| 536 | this.chunkProviderSettingsJson = original.getGeneratorOptions();
|
| 537 | this.generateStructuresEnabled = original.isMapFeaturesEnabled();
|
| 538 | this.allowCheats = original.areCommandsAllowed();
|
| 539 |
|
| 540 | if (original.isHardcoreModeEnabled())
|
| 541 | {
|
| 542 | this.gameMode = "hardcore";
|
| 543 | }
|
| 544 | else if (original.getGameType().isSurvivalOrAdventure())
|
| 545 | {
|
| 546 | this.gameMode = "survival";
|
| 547 | }
|
| 548 | else if (original.getGameType().isCreative())
|
| 549 | {
|
| 550 | this.gameMode = "creative";
|
| 551 | }
|
| 552 | }
|
| 553 | }
|
| 554 |
|