need to remove sp classes from clientside source

This commit is contained in:
catfoolyou
2025-03-21 17:00:42 -04:00
parent 75ae2b02c8
commit 1d659d2493
18 changed files with 1735221 additions and 37380 deletions

View File

@@ -1,13 +1,12 @@
package net.minecraft.src;
import java.util.List;
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.EaglercraftRandom;
import net.lax1dude.eaglercraft.IntegratedServer;
import java.util.List;
public class GuiCreateWorld extends GuiScreen
{
public class GuiCreateWorld extends GuiScreen {
private GuiScreen parentGuiScreen;
private GuiTextField textboxWorldName;
private GuiTextField textboxSeed;
@@ -16,20 +15,21 @@ public class GuiCreateWorld extends GuiScreen
/** hardcore', 'creative' or 'survival */
private String gameMode = "survival";
private boolean generateStructures = true;
private boolean commandsAllowed;
private boolean commandsAllowed = false;
/** True iif player has clicked buttonAllowCommands at least once */
private boolean commandsToggled;
private boolean commandsToggled = false;
/** toggles when GUIButton 7 is pressed */
private boolean bonusItems;
private boolean bonusItems = false;
/** True if and only if gameMode.equals("hardcore") */
private boolean isHardcore;
private boolean isHardcore = false;
private boolean createClicked;
/**
* True if the extra options (Seed box, structure toggle button, world type button, etc.) are being shown
* True if the extra options (Seed box, structure toggle button, world type
* button, etc.) are being shown
*/
private boolean moreOptions;
@@ -37,7 +37,8 @@ public class GuiCreateWorld extends GuiScreen
private GuiButton buttonGameMode;
/**
* The GUIButton that you click to get to options like the seed when creating a world.
* The GUIButton that you click to get to options like the seed when creating a
* world.
*/
private GuiButton moreWorldOptions;
@@ -63,7 +64,7 @@ public class GuiCreateWorld extends GuiScreen
/** E.g. New World, Neue Welt, Nieuwe wereld, Neuvo Mundo */
private String localizedNewWorldText;
private int worldTypeId;
private int worldTypeId = 0;
/** Generator options to use when creating the world. */
public String generatorOptionsToUse = "";
@@ -71,10 +72,11 @@ public class GuiCreateWorld extends GuiScreen
/**
* If the world name is one of these, it'll be surrounded with underscores.
*/
private static final String[] ILLEGAL_WORLD_NAMES = 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"};
private static final String[] ILLEGAL_WORLD_NAMES = 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" };
public GuiCreateWorld(GuiScreen par1GuiScreen)
{
public GuiCreateWorld(GuiScreen par1GuiScreen) {
this.parentGuiScreen = par1GuiScreen;
this.seed = "";
this.localizedNewWorldText = StatCollector.translateToLocal("selectWorld.newWorld");
@@ -83,8 +85,7 @@ public class GuiCreateWorld extends GuiScreen
/**
* Called from the main game loop to update the screen.
*/
public void updateScreen()
{
public void updateScreen() {
this.textboxWorldName.updateCursorCounter();
this.textboxSeed.updateCursorCounter();
}
@@ -92,23 +93,31 @@ public class GuiCreateWorld extends GuiScreen
/**
* Adds the buttons (and other controls) to the screen in question.
*/
public void initGui()
{
public void initGui() {
StringTranslate var1 = StringTranslate.getInstance();
EaglerAdapter.enableRepeatEvents(true);
this.buttonList.clear();
this.buttonList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, StatCollector.translateToLocal("selectWorld.create")));
this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, StatCollector.translateToLocal("gui.cancel")));
this.buttonList.add(this.buttonGameMode = new GuiButton(2, this.width / 2 - 75, 115, 150, 20, StatCollector.translateToLocal("selectWorld.gameMode")));
this.buttonList.add(this.moreWorldOptions = new GuiButton(3, this.width / 2 - 75, 187, 150, 20, StatCollector.translateToLocal("selectWorld.moreWorldOptions")));
this.buttonList.add(this.buttonGenerateStructures = new GuiButton(4, this.width / 2 - 155, 100, 150, 20, StatCollector.translateToLocal("selectWorld.mapFeatures")));
this.buttonList.add(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20,
var1.translateKey("selectWorld.create")));
this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, var1.translateKey("gui.cancel")));
this.buttonList.add(this.buttonGameMode = new GuiButton(2, this.width / 2 - 75, 115, 150, 20,
var1.translateKey("selectWorld.gameMode")));
this.buttonList.add(this.moreWorldOptions = new GuiButton(3, this.width / 2 - 75, 187, 150, 20,
var1.translateKey("selectWorld.moreWorldOptions")));
this.buttonList.add(this.buttonGenerateStructures = new GuiButton(4, this.width / 2 - 155, 100, 150, 20,
var1.translateKey("selectWorld.mapFeatures")));
this.buttonGenerateStructures.drawButton = false;
this.buttonList.add(this.buttonBonusItems = new GuiButton(7, this.width / 2 + 5, 151, 150, 20, StatCollector.translateToLocal("selectWorld.bonusItems")));
this.buttonList.add(this.buttonBonusItems = new GuiButton(7, this.width / 2 + 5, 151, 150, 20,
var1.translateKey("selectWorld.bonusItems")));
this.buttonBonusItems.drawButton = false;
this.buttonList.add(this.buttonWorldType = new GuiButton(5, this.width / 2 + 5, 100, 150, 20, StatCollector.translateToLocal("selectWorld.mapType")));
this.buttonList.add(this.buttonWorldType = new GuiButton(5, this.width / 2 + 5, 100, 150, 20,
var1.translateKey("selectWorld.mapType")));
this.buttonWorldType.drawButton = false;
this.buttonList.add(this.buttonAllowCommands = new GuiButton(6, this.width / 2 - 155, 151, 150, 20, StatCollector.translateToLocal("selectWorld.allowCommands")));
this.buttonList.add(this.buttonAllowCommands = new GuiButton(6, this.width / 2 - 155, 151, 150, 20,
var1.translateKey("selectWorld.allowCommands")));
this.buttonAllowCommands.drawButton = false;
this.buttonList.add(this.buttonCustomize = new GuiButton(8, this.width / 2 + 5, 120, 150, 20, StatCollector.translateToLocal("selectWorld.customizeType")));
this.buttonList.add(this.buttonCustomize = new GuiButton(8, this.width / 2 + 5, 120, 150, 20,
var1.translateKey("selectWorld.customizeType")));
this.buttonCustomize.drawButton = false;
this.textboxWorldName = new GuiTextField(this.fontRenderer, this.width / 2 - 100, 60, 200, 20);
this.textboxWorldName.setFocused(true);
@@ -121,8 +130,9 @@ public class GuiCreateWorld extends GuiScreen
}
/**
* Makes a the name for a world save folder based on your world name, replacing specific characters for _s and
* appending -s to the end until a free name is available.
* Makes a the name for a world save folder based on your world name, replacing
* specific characters for _s and appending -s to the end until a free name is
* available.
*/
private void makeUseableName() {
this.folderName = makeUsableName(this.textboxWorldName.getText().trim());
@@ -143,43 +153,41 @@ public class GuiCreateWorld extends GuiScreen
return func_73913_a(s);
}
private void updateButtonText()
{
this.buttonGameMode.displayString = StatCollector.translateToLocal("selectWorld.gameMode") + " " + StatCollector.translateToLocal("selectWorld.gameMode." + this.gameMode);
this.gameModeDescriptionLine1 = StatCollector.translateToLocal("selectWorld.gameMode." + this.gameMode + ".line1");
this.gameModeDescriptionLine2 = StatCollector.translateToLocal("selectWorld.gameMode." + this.gameMode + ".line2");
this.buttonGenerateStructures.displayString = StatCollector.translateToLocal("selectWorld.mapFeatures") + " ";
private void updateButtonText() {
StringTranslate var1 = StringTranslate.getInstance();
this.buttonGameMode.displayString = var1.translateKey("selectWorld.gameMode") + " "
+ var1.translateKey("selectWorld.gameMode." + this.gameMode);
this.gameModeDescriptionLine1 = var1.translateKey("selectWorld.gameMode." + this.gameMode + ".line1");
this.gameModeDescriptionLine2 = var1.translateKey("selectWorld.gameMode." + this.gameMode + ".line2");
this.buttonGenerateStructures.displayString = var1.translateKey("selectWorld.mapFeatures") + " ";
if (this.generateStructures)
{
this.buttonGenerateStructures.displayString = this.buttonGenerateStructures.displayString + StatCollector.translateToLocal("options.on");
}
else
{
this.buttonGenerateStructures.displayString = this.buttonGenerateStructures.displayString + StatCollector.translateToLocal("options.off");
if (this.generateStructures) {
this.buttonGenerateStructures.displayString = this.buttonGenerateStructures.displayString
+ var1.translateKey("options.on");
} else {
this.buttonGenerateStructures.displayString = this.buttonGenerateStructures.displayString
+ var1.translateKey("options.off");
}
this.buttonBonusItems.displayString = StatCollector.translateToLocal("selectWorld.bonusItems") + " ";
this.buttonBonusItems.displayString = var1.translateKey("selectWorld.bonusItems") + " ";
if (this.bonusItems && !this.isHardcore)
{
this.buttonBonusItems.displayString = this.buttonBonusItems.displayString + StatCollector.translateToLocal("options.on");
}
else
{
this.buttonBonusItems.displayString = this.buttonBonusItems.displayString + StatCollector.translateToLocal("options.off");
if (this.bonusItems && !this.isHardcore) {
this.buttonBonusItems.displayString = this.buttonBonusItems.displayString + var1.translateKey("options.on");
} else {
this.buttonBonusItems.displayString = this.buttonBonusItems.displayString
+ var1.translateKey("options.off");
}
this.buttonWorldType.displayString = StatCollector.translateToLocal("selectWorld.mapType") + " " + StatCollector.translateToLocal(WorldType.worldTypes[this.worldTypeId].getTranslateName());
this.buttonAllowCommands.displayString = StatCollector.translateToLocal("selectWorld.allowCommands") + " ";
this.buttonWorldType.displayString = var1.translateKey("selectWorld.mapType") + " "
+ var1.translateKey(WorldType.worldTypes[this.worldTypeId].getTranslateName());
this.buttonAllowCommands.displayString = var1.translateKey("selectWorld.allowCommands") + " ";
if (this.commandsAllowed && !this.isHardcore)
{
this.buttonAllowCommands.displayString = this.buttonAllowCommands.displayString + StatCollector.translateToLocal("options.on");
}
else
{
this.buttonAllowCommands.displayString = this.buttonAllowCommands.displayString + StatCollector.translateToLocal("options.off");
if (this.commandsAllowed && !this.isHardcore) {
this.buttonAllowCommands.displayString = this.buttonAllowCommands.displayString
+ var1.translateKey("options.on");
} else {
this.buttonAllowCommands.displayString = this.buttonAllowCommands.displayString
+ var1.translateKey("options.off");
}
}
@@ -216,28 +224,22 @@ public class GuiCreateWorld extends GuiScreen
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
public void onGuiClosed() {
EaglerAdapter.enableRepeatEvents(false);
}
/**
* Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
* Fired when a control is clicked. This is the equivalent of
* ActionListener.actionPerformed(ActionEvent e).
*/
protected void actionPerformed(GuiButton par1GuiButton)
{
if (par1GuiButton.enabled)
{
if (par1GuiButton.id == 1)
{
protected void actionPerformed(GuiButton par1GuiButton) {
if (par1GuiButton.enabled) {
if (par1GuiButton.id == 1) {
this.mc.displayGuiScreen(this.parentGuiScreen);
}
else if (par1GuiButton.id == 0)
{
this.mc.displayGuiScreen((GuiScreen)null);
} else if (par1GuiButton.id == 0) {
this.mc.displayGuiScreen((GuiScreen) null);
if (this.createClicked)
{
if (this.createClicked) {
return;
}
@@ -245,50 +247,38 @@ public class GuiCreateWorld extends GuiScreen
long var2 = (new EaglercraftRandom()).nextLong();
String var4 = this.textboxSeed.getText();
if (!MathHelper.stringNullOrLengthZero(var4))
{
try
{
if (!MathHelper.stringNullOrLengthZero(var4)) {
try {
long var5 = Long.parseLong(var4);
if (var5 != 0L)
{
if (var5 != 0L) {
var2 = var5;
}
}
catch (NumberFormatException var7)
{
var2 = (long)var4.hashCode();
} catch (NumberFormatException var7) {
var2 = (long) var4.hashCode();
}
}
EnumGameType var8 = EnumGameType.getByName(this.gameMode);
WorldSettings var6 = new WorldSettings(var2, var8, this.generateStructures, this.isHardcore, WorldType.worldTypes[this.worldTypeId]);
WorldSettings var6 = new WorldSettings(var2, var8, this.generateStructures, this.isHardcore,
WorldType.worldTypes[this.worldTypeId]);
var6.func_82750_a(this.generatorOptionsToUse);
if (this.bonusItems && !this.isHardcore)
{
if (this.bonusItems && !this.isHardcore) {
var6.enableBonusChest();
}
if (this.commandsAllowed && !this.isHardcore)
{
if (this.commandsAllowed && !this.isHardcore) {
var6.enableCommands();
}
System.out.println("created world, launching integratedserver");
this.mc.launchIntegratedServer(this.folderName, this.textboxWorldName.getText().trim(), var6);
//this.mc.statFileWriter.readStat(StatList.createWorldStat, 1);
}
else if (par1GuiButton.id == 3)
{
} else if (par1GuiButton.id == 3) {
this.func_82287_i();
}
else if (par1GuiButton.id == 2)
{
if (this.gameMode.equals("survival"))
{
if (!this.commandsToggled)
{
} else if (par1GuiButton.id == 2) {
if (this.gameMode.equals("survival")) {
if (!this.commandsToggled) {
this.commandsAllowed = false;
}
@@ -298,11 +288,8 @@ public class GuiCreateWorld extends GuiScreen
this.buttonAllowCommands.enabled = false;
this.buttonBonusItems.enabled = false;
this.updateButtonText();
}
else if (this.gameMode.equals("hardcore"))
{
if (!this.commandsToggled)
{
} else if (this.gameMode.equals("hardcore")) {
if (!this.commandsToggled) {
this.commandsAllowed = true;
}
@@ -312,11 +299,8 @@ public class GuiCreateWorld extends GuiScreen
this.isHardcore = false;
this.buttonAllowCommands.enabled = true;
this.buttonBonusItems.enabled = true;
}
else
{
if (!this.commandsToggled)
{
} else {
if (!this.commandsToggled) {
this.commandsAllowed = false;
}
@@ -328,32 +312,24 @@ public class GuiCreateWorld extends GuiScreen
}
this.updateButtonText();
}
else if (par1GuiButton.id == 4)
{
} else if (par1GuiButton.id == 4) {
this.generateStructures = !this.generateStructures;
this.updateButtonText();
}
else if (par1GuiButton.id == 7)
{
} else if (par1GuiButton.id == 7) {
this.bonusItems = !this.bonusItems;
this.updateButtonText();
}
else if (par1GuiButton.id == 5)
{
} else if (par1GuiButton.id == 5) {
++this.worldTypeId;
if (this.worldTypeId >= WorldType.worldTypes.length)
{
if (this.worldTypeId >= WorldType.worldTypes.length) {
this.worldTypeId = 0;
}
while (WorldType.worldTypes[this.worldTypeId] == null || !WorldType.worldTypes[this.worldTypeId].getCanBeCreated())
{
while (WorldType.worldTypes[this.worldTypeId] == null
|| !WorldType.worldTypes[this.worldTypeId].getCanBeCreated()) {
++this.worldTypeId;
if (this.worldTypeId >= WorldType.worldTypes.length)
{
if (this.worldTypeId >= WorldType.worldTypes.length) {
this.worldTypeId = 0;
}
}
@@ -361,27 +337,21 @@ public class GuiCreateWorld extends GuiScreen
this.generatorOptionsToUse = "";
this.updateButtonText();
this.func_82288_a(this.moreOptions);
}
else if (par1GuiButton.id == 6)
{
} else if (par1GuiButton.id == 6) {
this.commandsToggled = true;
this.commandsAllowed = !this.commandsAllowed;
this.updateButtonText();
}
else if (par1GuiButton.id == 8)
{
} else if (par1GuiButton.id == 8) {
this.mc.displayGuiScreen(new GuiCreateFlatWorld(this, this.generatorOptionsToUse));
}
}
}
private void func_82287_i()
{
private void func_82287_i() {
this.func_82288_a(!this.moreOptions);
}
private void func_82288_a(boolean par1)
{
private void func_82288_a(boolean par1) {
this.moreOptions = par1;
this.buttonGameMode.drawButton = !this.moreOptions;
this.buttonGenerateStructures.drawButton = this.moreOptions;
@@ -389,55 +359,47 @@ public class GuiCreateWorld extends GuiScreen
this.buttonWorldType.drawButton = this.moreOptions;
this.buttonAllowCommands.drawButton = this.moreOptions;
this.buttonCustomize.drawButton = this.moreOptions && WorldType.worldTypes[this.worldTypeId] == WorldType.FLAT;
StringTranslate var2;
if (this.moreOptions)
{
this.moreWorldOptions.displayString = StatCollector.translateToLocal("gui.done");
}
else
{
this.moreWorldOptions.displayString = StatCollector.translateToLocal("selectWorld.moreWorldOptions");
if (this.moreOptions) {
var2 = StringTranslate.getInstance();
this.moreWorldOptions.displayString = var2.translateKey("gui.done");
} else {
var2 = StringTranslate.getInstance();
this.moreWorldOptions.displayString = var2.translateKey("selectWorld.moreWorldOptions");
}
}
/**
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
* Fired when a key is typed. This is the equivalent of
* KeyListener.keyTyped(KeyEvent e).
*/
protected void keyTyped(char par1, int par2)
{
if (this.textboxWorldName.isFocused() && !this.moreOptions)
{
protected void keyTyped(char par1, int par2) {
if (this.textboxWorldName.isFocused() && !this.moreOptions) {
this.textboxWorldName.textboxKeyTyped(par1, par2);
this.localizedNewWorldText = this.textboxWorldName.getText();
}
else if (this.textboxSeed.isFocused() && this.moreOptions)
{
} else if (this.textboxSeed.isFocused() && this.moreOptions) {
this.textboxSeed.textboxKeyTyped(par1, par2);
this.seed = this.textboxSeed.getText();
}
if (par2 == 28 || par2 == 156)
{
this.actionPerformed((GuiButton)this.buttonList.get(0));
if (par1 == 13) {
this.actionPerformed((GuiButton) this.buttonList.get(0));
}
((GuiButton)this.buttonList.get(0)).enabled = this.textboxWorldName.getText().length() > 0;
((GuiButton) this.buttonList.get(0)).enabled = this.textboxWorldName.getText().length() > 0;
this.makeUseableName();
}
/**
* Called when the mouse is clicked.
*/
protected void mouseClicked(int par1, int par2, int par3)
{
protected void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
if (this.moreOptions)
{
if (this.moreOptions) {
this.textboxSeed.mouseClicked(par1, par2, par3);
}
else
{
} else {
this.textboxWorldName.mouseClicked(par1, par2, par3);
}
}
@@ -445,23 +407,27 @@ public class GuiCreateWorld extends GuiScreen
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int par1, int par2, float par3)
{
public void drawScreen(int par1, int par2, float par3) {
StringTranslate var4 = StringTranslate.getInstance();
this.drawDefaultBackground();
this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("selectWorld.create"), this.width / 2, 20, 16777215);
this.drawCenteredString(this.fontRenderer, var4.translateKey("selectWorld.create"), this.width / 2, 20,
16777215);
if (this.moreOptions)
{
this.drawString(this.fontRenderer, StatCollector.translateToLocal("selectWorld.enterSeed"), this.width / 2 - 100, 47, 10526880);
this.drawString(this.fontRenderer, StatCollector.translateToLocal("selectWorld.seedInfo"), this.width / 2 - 100, 85, 10526880);
this.drawString(this.fontRenderer, StatCollector.translateToLocal("selectWorld.mapFeatures.info"), this.width / 2 - 150, 122, 10526880);
this.drawString(this.fontRenderer, StatCollector.translateToLocal("selectWorld.allowCommands.info"), this.width / 2 - 150, 172, 10526880);
if (this.moreOptions) {
this.drawString(this.fontRenderer, var4.translateKey("selectWorld.enterSeed"), this.width / 2 - 100, 47,
10526880);
this.drawString(this.fontRenderer, var4.translateKey("selectWorld.seedInfo"), this.width / 2 - 100, 85,
10526880);
this.drawString(this.fontRenderer, var4.translateKey("selectWorld.mapFeatures.info"), this.width / 2 - 150,
122, 10526880);
this.drawString(this.fontRenderer, var4.translateKey("selectWorld.allowCommands.info"),
this.width / 2 - 150, 172, 10526880);
this.textboxSeed.drawTextBox();
}
else
{
this.drawString(this.fontRenderer, StatCollector.translateToLocal("selectWorld.enterName"), this.width / 2 - 100, 47, 10526880);
this.drawString(this.fontRenderer, StatCollector.translateToLocal("selectWorld.resultFolder") + " " + this.folderName, this.width / 2 - 100, 85, 10526880);
} else {
this.drawString(this.fontRenderer, var4.translateKey("selectWorld.enterName"), this.width / 2 - 100, 47,
10526880);
this.drawString(this.fontRenderer, var4.translateKey("selectWorld.resultFolder") + " " + this.folderName,
this.width / 2 - 100, 85, 10526880);
this.textboxWorldName.drawTextBox();
this.drawString(this.fontRenderer, this.gameModeDescriptionLine1, this.width / 2 - 100, 137, 10526880);
this.drawString(this.fontRenderer, this.gameModeDescriptionLine2, this.width / 2 - 100, 149, 10526880);
@@ -472,23 +438,18 @@ public class GuiCreateWorld extends GuiScreen
public void func_82286_a(WorldInfo par1WorldInfo)
{
this.localizedNewWorldText = StatCollector.translateToLocalFormatted("selectWorld.newWorld.copyOf", new Object[] {par1WorldInfo.getWorldName()});
this.localizedNewWorldText = StatCollector.translateToLocalFormatted("selectWorld.newWorld.copyOf", par1WorldInfo.getWorldName());
this.seed = par1WorldInfo.getSeed() + "";
this.worldTypeId = par1WorldInfo.getTerrainType().getWorldTypeID();
this.generatorOptionsToUse = par1WorldInfo.getGeneratorOptions();
this.generateStructures = par1WorldInfo.isMapFeaturesEnabled();
this.commandsAllowed = par1WorldInfo.areCommandsAllowed();
if (par1WorldInfo.isHardcoreModeEnabled())
{
if (par1WorldInfo.isHardcoreModeEnabled()) {
this.gameMode = "hardcore";
}
else if (par1WorldInfo.getGameType().isSurvivalOrAdventure())
{
} else if (par1WorldInfo.getGameType().isSurvivalOrAdventure()) {
this.gameMode = "survival";
}
else if (par1WorldInfo.getGameType().isCreative())
{
} else if (par1WorldInfo.getGameType().isCreative()) {
this.gameMode = "creative";
}
}

View File

@@ -1,19 +1,25 @@
package net.minecraft.src;
import net.lax1dude.eaglercraft.IntegratedServer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class GuiSelectWorld extends GuiScreen
{
import net.lax1dude.eaglercraft.EaglerAdapter;
import net.lax1dude.eaglercraft.GuiScreenBackupWorld;
import net.lax1dude.eaglercraft.GuiScreenCreateWorldSelection;
import net.lax1dude.eaglercraft.GuiScreenLANConnect;
import net.lax1dude.eaglercraft.GuiScreenSingleplayerLoading;
import net.lax1dude.eaglercraft.IntegratedServer;
public class GuiSelectWorld extends GuiScreen {
/** simple date formater */
private final DateFormat dateFormatter = new SimpleDateFormat();
/**
* A reference to the screen object that created this. Used for navigating between screens.
* A reference to the screen object that created this. Used for navigating
* between screens.
*/
protected GuiScreen parentScreen;
@@ -21,13 +27,13 @@ public class GuiSelectWorld extends GuiScreen
protected String screenTitle = "Select world";
/** True if a world has been selected. */
private boolean selected;
private boolean selected = false;
/** the currently selected world */
private int selectedWorld;
/** The save list for the world selection screen */
private List saveList;
private List<SaveFormatComparator> saveList;
private GuiWorldSlot worldSlotContainer;
/** E.g. World, Welt, Monde, Mundo */
@@ -35,7 +41,8 @@ public class GuiSelectWorld extends GuiScreen
private String localizedMustConvertText;
/**
* The game mode text that is displayed with each world on the world selection list.
* The game mode text that is displayed with each world on the world selection
* list.
*/
private String[] localizedGameModeText = new String[3];
@@ -50,41 +57,53 @@ public class GuiSelectWorld extends GuiScreen
/** The rename button in the world selection GUI */
private GuiButton buttonRename;
private GuiButton buttonRecreate;
private GuiButton buttonBackup;
public GuiSelectWorld(GuiScreen par1GuiScreen)
{
private boolean hasRequestedWorlds = false;
private boolean waitingForWorlds = false;
public GuiSelectWorld(GuiScreen par1GuiScreen) {
this.parentScreen = par1GuiScreen;
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
public void initGui()
{
this.screenTitle = StatCollector.translateToLocal("selectWorld.title");
public void initGui() {
StringTranslate var1 = StringTranslate.getInstance();
this.screenTitle = var1.translateKey("selectWorld.title");
this.saveList = new LinkedList();
try
{
this.loadSaves();
}
catch (Exception var2)
{
var2.printStackTrace();
this.mc.displayGuiScreen(new GuiErrorScreen("Unable to load words", var2.getMessage()));
return;
if(IntegratedServer.isReady()) {
hasRequestedWorlds = true;
waitingForWorlds = true;
IntegratedServer.requestWorldList();
}else {
IntegratedServer.unloadWorld();
hasRequestedWorlds = false;
}
this.localizedWorldText = StatCollector.translateToLocal("selectWorld.world");
this.localizedMustConvertText = StatCollector.translateToLocal("selectWorld.conversion");
this.localizedGameModeText[EnumGameType.SURVIVAL.getID()] = StatCollector.translateToLocal("gameMode.survival");
this.localizedGameModeText[EnumGameType.CREATIVE.getID()] = StatCollector.translateToLocal("gameMode.creative");
this.localizedGameModeText[EnumGameType.ADVENTURE.getID()] = StatCollector.translateToLocal("gameMode.adventure");
this.localizedWorldText = var1.translateKey("selectWorld.world");
this.localizedMustConvertText = var1.translateKey("selectWorld.conversion");
this.localizedGameModeText[EnumGameType.SURVIVAL.getID()] = var1.translateKey("gameMode.survival");
this.localizedGameModeText[EnumGameType.CREATIVE.getID()] = var1.translateKey("gameMode.creative");
this.localizedGameModeText[EnumGameType.ADVENTURE.getID()] = var1.translateKey("gameMode.adventure");
this.worldSlotContainer = new GuiWorldSlot(this);
this.worldSlotContainer.registerScrollButtons(this.buttonList, 4, 5);
this.initButtons();
}
public void updateScreen() {
if(!hasRequestedWorlds && IntegratedServer.isReady()) {
hasRequestedWorlds = true;
waitingForWorlds = true;
IntegratedServer.requestWorldList();
}else if(waitingForWorlds && IntegratedServer.getWorldList() != null) {
waitingForWorlds = false;
this.loadSaves();
}
}
/**
* loads the saves
*/
@@ -94,7 +113,7 @@ public class GuiSelectWorld extends GuiScreen
for(NBTTagCompound n : levels) {
WorldInfo w = new WorldInfo(n.getCompoundTag("Data"));
this.saveList.add(new SaveFormatComparator(n.getString("folderName"), w.getWorldName(), w.getLastTimePlayed(),
w.getSizeOnDisk(), w.getGameType(), false, w.isHardcoreModeEnabled(), w.areCommandsAllowed())); // n was at the end, FIX THIS SHIT
w.getSizeOnDisk(), w.getGameType(), false, w.isHardcoreModeEnabled(), w.areCommandsAllowed(), n));
}
Collections.sort(this.saveList);
this.selectedWorld = -1;
@@ -103,21 +122,19 @@ public class GuiSelectWorld extends GuiScreen
/**
* returns the file name of the specified save number
*/
protected String getSaveFileName(int par1)
{
return ((SaveFormatComparator)this.saveList.get(par1)).getFileName();
protected String getSaveFileName(int par1) {
return ((SaveFormatComparator) this.saveList.get(par1)).getFileName();
}
/**
* returns the name of the saved game
*/
protected String getSaveName(int par1)
{
String var2 = ((SaveFormatComparator)this.saveList.get(par1)).getDisplayName();
protected String getSaveName(int par1) {
String var2 = ((SaveFormatComparator) this.saveList.get(par1)).getDisplayName();
if (var2 == null || MathHelper.stringNullOrLengthZero(var2))
{
var2 = StatCollector.translateToLocal("selectWorld.world") + " " + (par1 + 1);
if (var2 == null || MathHelper.stringNullOrLengthZero(var2)) {
StringTranslate var3 = StringTranslate.getInstance();
var2 = var3.translateKey("selectWorld.world") + " " + (par1 + 1);
}
return var2;
@@ -126,65 +143,50 @@ public class GuiSelectWorld extends GuiScreen
/**
* intilize the buttons for this GUI
*/
public void initButtons()
{
this.buttonList.add(this.buttonSelect = new GuiButton(1, this.width / 2 - 154, this.height - 52, 150, 20, StatCollector.translateToLocal("selectWorld.select")));
this.buttonList.add(new GuiButton(3, this.width / 2 + 4, this.height - 52, 150, 20, StatCollector.translateToLocal("selectWorld.create")));
this.buttonList.add(this.buttonRename = new GuiButton(6, this.width / 2 - 154, this.height - 28, 72, 20, StatCollector.translateToLocal("selectWorld.rename")));
this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 76, this.height - 28, 72, 20, StatCollector.translateToLocal("selectWorld.delete")));
this.buttonList.add(this.buttonRecreate = new GuiButton(7, this.width / 2 + 4, this.height - 28, 72, 20, StatCollector.translateToLocal("selectWorld.recreate")));
this.buttonList.add(new GuiButton(0, this.width / 2 + 82, this.height - 28, 72, 20, StatCollector.translateToLocal("gui.cancel")));
public void initButtons() {
StringTranslate var1 = StringTranslate.getInstance();
this.buttonList.add(this.buttonSelect = new GuiButton(1, this.width / 2 - 154, this.height - 52, 150, 20, var1.translateKey("selectWorld.select")));
this.buttonList.add(new GuiButton(3, this.width / 2 + 4, this.height - 52, 150, 20, var1.translateKey("selectWorld.create")));
this.buttonList.add(this.buttonRename = new GuiButton(6, this.width / 2 - 154, this.height - 28, 72, 20, var1.translateKey("selectWorld.rename")));
this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 76, this.height - 28, 72, 20, var1.translateKey("selectWorld.delete")));
this.buttonList.add(this.buttonBackup = new GuiButton(7, this.width / 2 + 4, this.height - 28, 72, 20, var1.translateKey("selectWorld.backup")));
this.buttonList.add(new GuiButton(0, this.width / 2 + 82, this.height - 28, 72, 20, var1.translateKey("gui.cancel")));
this.buttonSelect.enabled = false;
this.buttonDelete.enabled = false;
this.buttonRename.enabled = false;
this.buttonRecreate.enabled = false;
this.buttonBackup.enabled = false;
}
/**
* Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
* Fired when a control is clicked. This is the equivalent of
* ActionListener.actionPerformed(ActionEvent e).
*/
protected void actionPerformed(GuiButton par1GuiButton)
{
if (par1GuiButton.enabled)
{
if (par1GuiButton.id == 2)
{
protected void actionPerformed(GuiButton par1GuiButton) {
if (par1GuiButton.enabled) {
if (par1GuiButton.id == 2) {
String var2 = this.getSaveName(this.selectedWorld);
if (var2 != null)
{
if (var2 != null) {
this.deleting = true;
GuiYesNo var3 = getDeleteWorldScreen(this, var2, this.selectedWorld);
this.mc.displayGuiScreen(var3);
}
}
else if (par1GuiButton.id == 1)
{
//this.mc.displayGuiScreen(new GuiScreenSingleplayerNotImplemented(this, "delete world"));
} else if (par1GuiButton.id == 1) {
this.selectWorld(this.selectedWorld);
}
else if (par1GuiButton.id == 3)
{
this.mc.displayGuiScreen(new GuiCreateWorld(this));
}
else if (par1GuiButton.id == 6)
{
} else if (par1GuiButton.id == 3) {
this.mc.displayGuiScreen(new GuiScreenCreateWorldSelection(this));
} else if (par1GuiButton.id == 6) {
this.mc.displayGuiScreen(new GuiRenameWorld(this, this.getSaveFileName(this.selectedWorld)));
}
else if (par1GuiButton.id == 0)
{
} else if (par1GuiButton.id == 0) {
this.mc.displayGuiScreen(this.parentScreen);
}
else if (par1GuiButton.id == 7)
{
GuiCreateWorld var5 = new GuiCreateWorld(this);
ISaveHandler var6 = this.mc.getSaveLoader().getSaveLoader(this.getSaveFileName(this.selectedWorld), false);
WorldInfo var4 = var6.loadWorldInfo();
var6.flush();
var5.func_82286_a(var4);
this.mc.displayGuiScreen(var5);
}
else
{
} else if (par1GuiButton.id == 7) {
//GuiCreateWorld var5 = new GuiCreateWorld(this);
//var5.func_82286_a(new WorldInfo(this.saveList.get(this.selectedWorld).levelDat));
//this.mc.displayGuiScreen(var5);
this.mc.displayGuiScreen(new GuiScreenBackupWorld(this, this.getSaveFileName(this.selectedWorld),
((SaveFormatComparator)getSize(this).get(selectedWorld)).levelDat));
} else {
this.worldSlotContainer.actionPerformed(par1GuiButton);
}
}
@@ -215,122 +217,124 @@ public class GuiSelectWorld extends GuiScreen
}
}
public void confirmClicked(boolean par1, int par2)
{
if (this.deleting)
{
public void confirmClicked(boolean par1, int par2) {
if (this.deleting) {
this.deleting = false;
if (par1)
{
ISaveFormat var3 = this.mc.getSaveLoader();
var3.flushCache();
var3.deleteWorldDirectory(this.getSaveFileName(par2));
try
{
this.loadSaves();
}
catch (Exception var5)
{
var5.printStackTrace();
}
/*
if (par1) {
waitingForWorlds = true;
IntegratedServer.requestWorldList();
}
*/
if (par1) {
IntegratedServer.deleteWorld(this.getSaveFileName(par2));
this.mc.displayGuiScreen(new GuiScreenSingleplayerLoading(this, "selectWorld.progress.deleting", () -> IntegratedServer.isReady()));
}else {
this.mc.displayGuiScreen(this);
}
this.mc.displayGuiScreen(this);
}
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int par1, int par2, float par3)
{
public void drawScreen(int par1, int par2, float par3) {
this.worldSlotContainer.drawScreen(par1, par2, par3);
this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 20, 16777215);
// EaglerAdapter.glPushMatrix();
// EaglerAdapter.glScalef(0.75f, 0.75f, 0.75f);
//
// String text = StringTranslate.getInstance().translateKey("directConnect.lanWorld");
// int w = mc.fontRenderer.getStringWidth(text);
// boolean hover = par1 > 1 && par2 > 1 && par1 < (w * 3 / 4) + 7 && par2 < 12;
//
// drawString(mc.fontRenderer, EnumChatFormatting.UNDERLINE + text, 5, 5, hover ? 0xFFEEEE22 : 0xFFCCCCCC);
//
// EaglerAdapter.glPopMatrix();
super.drawScreen(par1, par2, par3);
}
public void mouseClicked(int xx, int yy, int btn) {
String text = StringTranslate.getInstance().translateKey("directConnect.lanWorld");
int w = mc.fontRenderer.getStringWidth(text);
if(xx > 2 && yy > 2 && xx < (w * 3 / 4) + 5 && yy < 12) {
mc.displayGuiScreen(new GuiScreenLANConnect(this));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
super.mouseClicked(xx, yy, btn);
}
/**
* Gets a GuiYesNo screen with the warning, buttons, etc.
*/
public static GuiYesNo getDeleteWorldScreen(GuiScreen par0GuiScreen, String par1Str, int par2)
{
String var3 = StatCollector.translateToLocal("selectWorld.deleteQuestion");
String var4 = "\'" + par1Str + "\' " + StatCollector.translateToLocal("selectWorld.deleteWarning");
String var5 = StatCollector.translateToLocal("selectWorld.deleteButton");
String var6 = StatCollector.translateToLocal("gui.cancel");
GuiYesNo var7 = new GuiYesNo(par0GuiScreen, var3, var4, var5, var6, par2);
return var7;
public static GuiYesNo getDeleteWorldScreen(GuiScreen par0GuiScreen, String par1Str, int par2) {
StringTranslate var3 = StringTranslate.getInstance();
String var4 = var3.translateKey("selectWorld.deleteQuestion");
String var5 = "\'" + par1Str + "\' " + var3.translateKey("selectWorld.deleteWarning");
String var6 = var3.translateKey("selectWorld.deleteButton");
String var7 = var3.translateKey("gui.cancel");
GuiYesNo var8 = new GuiYesNo(par0GuiScreen, var4, var5, var6, var7, par2);
return var8;
}
static List getSize(GuiSelectWorld par0GuiSelectWorld)
{
static List getSize(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.saveList;
}
/**
* called whenever an element in this gui is selected
*/
static int onElementSelected(GuiSelectWorld par0GuiSelectWorld, int par1)
{
static int onElementSelected(GuiSelectWorld par0GuiSelectWorld, int par1) {
return par0GuiSelectWorld.selectedWorld = par1;
}
/**
* returns the world currently selected
*/
static int getSelectedWorld(GuiSelectWorld par0GuiSelectWorld)
{
static int getSelectedWorld(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.selectedWorld;
}
/**
* returns the select button
*/
static GuiButton getSelectButton(GuiSelectWorld par0GuiSelectWorld)
{
static GuiButton getSelectButton(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.buttonSelect;
}
/**
* returns the rename button
*/
static GuiButton getRenameButton(GuiSelectWorld par0GuiSelectWorld)
{
static GuiButton getRenameButton(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.buttonDelete;
}
/**
* returns the delete button
*/
static GuiButton getDeleteButton(GuiSelectWorld par0GuiSelectWorld)
{
static GuiButton getDeleteButton(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.buttonRename;
}
static GuiButton func_82312_f(GuiSelectWorld par0GuiSelectWorld)
{
return par0GuiSelectWorld.buttonRecreate;
static GuiButton func_82312_f(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.buttonBackup;
}
static String func_82313_g(GuiSelectWorld par0GuiSelectWorld)
{
static String func_82313_g(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.localizedWorldText;
}
static DateFormat func_82315_h(GuiSelectWorld par0GuiSelectWorld)
{
static DateFormat func_82315_h(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.dateFormatter;
}
static String func_82311_i(GuiSelectWorld par0GuiSelectWorld)
{
static String func_82311_i(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.localizedMustConvertText;
}
static String[] func_82314_j(GuiSelectWorld par0GuiSelectWorld)
{
static String[] func_82314_j(GuiSelectWorld par0GuiSelectWorld) {
return par0GuiSelectWorld.localizedGameModeText;
}
}

View File

@@ -4,6 +4,7 @@ import net.lax1dude.eaglercraft.*;
import net.lax1dude.eaglercraft.adapter.Tessellator;
import net.lax1dude.eaglercraft.glemu.FixedFunctionShader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
@@ -1243,64 +1244,12 @@ public class Minecraft
/**
* Arguments: World foldername, World ingame name, WorldSettings
*/
public void launchIntegratedServer(String par1Str, String par2Str, WorldSettings par3WorldSettings) // FIX THIS SHIT
{
/*this.loadWorld((WorldClient)null);
System.gc();
ISaveHandler var4 = this.saveLoader.getSaveLoader(par1Str, false);
WorldInfo var5 = var4.loadWorldInfo();
public void launchIntegratedServer(String folderName, String trim, WorldSettings var6) {
this.loadWorld((WorldClient)null);
if (var5 == null && par3WorldSettings != null)
{
var5 = new WorldInfo(par3WorldSettings, par1Str);
var4.saveWorldInfo(var5);
}
IntegratedServer.loadWorld(folderName, gameSettings.difficulty, var6);
if (par3WorldSettings == null)
{
par3WorldSettings = new WorldSettings(var5);
}
this.statFileWriter.readStat(StatList.startGameStat, 1);
this.theIntegratedServer = new IntegratedServer(this, par1Str, par2Str, par3WorldSettings);
this.theIntegratedServer.startServerThread();
this.integratedServerIsRunning = true;
this.loadingScreen.displayProgressMessage(I18n.getString("menu.loadingLevel"));
while (!this.theIntegratedServer.serverIsInRunLoop())
{
String var6 = this.theIntegratedServer.getUserMessage();
if (var6 != null)
{
this.loadingScreen.resetProgresAndWorkingMessage(I18n.getString(var6));
}
else
{
this.loadingScreen.resetProgresAndWorkingMessage("");
}
try
{
Thread.sleep(200L);
}
catch (InterruptedException var9)
{
;
}
}
this.displayGuiScreen((GuiScreen)null);
try
{
NetClientHandler var10 = new NetClientHandler(this, this.theIntegratedServer);
this.myNetworkManager = var10.getNetManager();
}
catch (IOException var8)
{
this.displayCrashReport(this.addGraphicsAndWorldToCrashReport(new CrashReport("Connecting to integrated server", var8)));
}*/
this.displayGuiScreen(new GuiScreenSingleplayerLoading(new GuiScreenSingleplayerConnecting(new GuiMainMenu(), "Connecting to " + folderName), "Loading world: " + folderName, () -> IntegratedServer.isWorldRunning()));
}
/**

View File

@@ -1,7 +1,6 @@
package net.minecraft.src;
public class SaveFormatComparator implements Comparable
{
public class SaveFormatComparator implements Comparable {
/** the file name of this save */
private final String fileName;
@@ -16,8 +15,10 @@ public class SaveFormatComparator implements Comparable
private final boolean hardcore;
private final boolean cheatsEnabled;
public SaveFormatComparator(String par1Str, String par2Str, long par3, long par5, EnumGameType par7EnumGameType, boolean par8, boolean par9, boolean par10)
{
public final NBTTagCompound levelDat;
public SaveFormatComparator(String par1Str, String par2Str, long par3, long par5, EnumGameType par7EnumGameType,
boolean par8, boolean par9, boolean par10, NBTTagCompound levelDat) {
this.fileName = par1Str;
this.displayName = par2Str;
this.lastTimePlayed = par3;
@@ -26,62 +27,56 @@ public class SaveFormatComparator implements Comparable
this.requiresConversion = par8;
this.hardcore = par9;
this.cheatsEnabled = par10;
this.levelDat = levelDat;
}
/**
* return the file name
*/
public String getFileName()
{
public String getFileName() {
return this.fileName;
}
/**
* return the display name of the save
*/
public String getDisplayName()
{
public String getDisplayName() {
return this.displayName;
}
public boolean requiresConversion()
{
public boolean requiresConversion() {
return this.requiresConversion;
}
public long getLastTimePlayed()
{
public long getLastTimePlayed() {
return this.lastTimePlayed;
}
public int compareTo(SaveFormatComparator par1SaveFormatComparator)
{
return this.lastTimePlayed < par1SaveFormatComparator.lastTimePlayed ? 1 : (this.lastTimePlayed > par1SaveFormatComparator.lastTimePlayed ? -1 : this.fileName.compareTo(par1SaveFormatComparator.fileName));
public int compareTo(SaveFormatComparator par1SaveFormatComparator) {
return this.lastTimePlayed < par1SaveFormatComparator.lastTimePlayed ? 1
: (this.lastTimePlayed > par1SaveFormatComparator.lastTimePlayed ? -1
: this.fileName.compareTo(par1SaveFormatComparator.fileName));
}
/**
* Gets the EnumGameType.
*/
public EnumGameType getEnumGameType()
{
public EnumGameType getEnumGameType() {
return this.theEnumGameType;
}
public boolean isHardcoreModeEnabled()
{
public boolean isHardcoreModeEnabled() {
return this.hardcore;
}
/**
* @return {@code true} if cheats are enabled for this world
*/
public boolean getCheatsEnabled()
{
public boolean getCheatsEnabled() {
return this.cheatsEnabled;
}
public int compareTo(Object par1Obj)
{
return this.compareTo((SaveFormatComparator)par1Obj);
public int compareTo(Object par1Obj) {
return this.compareTo((SaveFormatComparator) par1Obj);
}
}