Merge branch 'singleplayer' of https://github.com/EaglerMods/eaglercraft-sp into singleplayer
This commit is contained in:
commit
aebd77e886
11
eaglercraft-sp.iml
Normal file
11
eaglercraft-sp.iml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="EclipseModuleManager">
|
||||
<conelement value="org.eclipse.buildship.core.gradleclasspathcontainer" />
|
||||
<src_description expected_position="0">
|
||||
<src_folder value="file://$MODULE_DIR$/src/main/java" expected_position="0" />
|
||||
<src_folder value="file://$MODULE_DIR$/src/teavm/java" expected_position="1" />
|
||||
<src_folder value="file://$MODULE_DIR$/sp-server/src/ipc/java" expected_position="2" />
|
||||
</src_description>
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -468,5 +468,5 @@ window.startLANServer = () => {
|
|||
if(typeof window.constructLANServer !== "function") {
|
||||
window.initializeLANServer();
|
||||
}
|
||||
return window.constructLANerver();
|
||||
return window.constructLANServer();
|
||||
};
|
||||
|
|
|
@ -32,6 +32,7 @@ menu.convertingLevel=Converting world
|
|||
menu.simulating=Simulating the world for a bit
|
||||
menu.respawning=Respawning
|
||||
menu.shareToLan=Open to LAN
|
||||
menu.closeLan=Close LAN
|
||||
|
||||
menu.skinCapeSettings=Skins/Capes Settings
|
||||
menu.skinCapeSettingsNote0=I put the button up here so
|
||||
|
@ -232,6 +233,7 @@ selectServer.direct=Direct Connect
|
|||
selectServer.edit=Edit
|
||||
selectServer.delete=Delete
|
||||
selectServer.add=Add server
|
||||
selectServer.lan=§3LAN
|
||||
selectServer.defaultName=Minecraft Server
|
||||
selectServer.deleteQuestion=Are you sure you want to remove this server?
|
||||
selectServer.deleteWarning=will be lost forever! (A long time!)
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.sp.ipc.*;
|
||||
import net.minecraft.src.EnumGameType;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NetHandler;
|
||||
import net.minecraft.src.WorldSettings;
|
||||
|
@ -427,4 +428,18 @@ public class IntegratedServer {
|
|||
sendIPCPacket(new IPCPacket0CPlayerChannel(channel, false));
|
||||
}
|
||||
|
||||
private static boolean hostingLAN = false;
|
||||
|
||||
public static final String shareToLAN(EnumGameType gameType, boolean allowCommands) {
|
||||
hostingLAN = true;
|
||||
return "yee";
|
||||
}
|
||||
|
||||
public static final void closeLAN() {
|
||||
hostingLAN = false;
|
||||
}
|
||||
|
||||
public static final boolean isHostingLAN() {
|
||||
return hostingLAN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.lax1dude.eaglercraft.ConfigConstants;
|
|||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.GuiScreenSkinCapeSettings;
|
||||
import net.lax1dude.eaglercraft.GuiVoiceMenu;
|
||||
import net.lax1dude.eaglercraft.IntegratedServer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class GuiIngameMenu extends GuiScreen {
|
||||
|
@ -30,8 +31,8 @@ public class GuiIngameMenu extends GuiScreen {
|
|||
this.buttonList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24 + var1, StatCollector.translateToLocal("menu.returnToGame")));
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal("menu.options")));
|
||||
GuiButton var3;
|
||||
this.buttonList.add(var3 = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal("menu.shareToLan")));
|
||||
var3.enabled = false;
|
||||
this.buttonList.add(var3 = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal(IntegratedServer.isHostingLAN() ? "menu.closeLan" : "menu.shareToLan")));
|
||||
var3.enabled = mc.isSingleplayer();
|
||||
this.buttonList.add(new GuiButton(8, 3, 3, 120, 20, StatCollector.translateToLocal("menu.skinCapeSettings")));
|
||||
}
|
||||
|
||||
|
@ -62,6 +63,17 @@ public class GuiIngameMenu extends GuiScreen {
|
|||
this.mc.sndManager.resumeAllSounds();
|
||||
break;
|
||||
|
||||
case 7:
|
||||
if (IntegratedServer.isHostingLAN()) {
|
||||
IntegratedServer.closeLAN();
|
||||
this.mc.displayGuiScreen((GuiScreen) null);
|
||||
this.mc.setIngameFocus();
|
||||
this.mc.sndManager.resumeAllSounds();
|
||||
} else {
|
||||
this.mc.displayGuiScreen(new GuiShareToLan(this));
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
this.mc.displayGuiScreen(new GuiScreenSkinCapeSettings(this));
|
||||
break;
|
||||
|
|
|
@ -123,13 +123,14 @@ public class GuiMultiplayer extends GuiScreen {
|
|||
*/
|
||||
public void initGuiControls() {
|
||||
StringTranslate var1 = StringTranslate.getInstance();
|
||||
this.buttonList.add(this.field_96289_p = new GuiButton(7, this.width / 2 - 154, this.height - 28, 70, 20, var1.translateKey("selectServer.edit")));
|
||||
this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 74, this.height - 28, 70, 20, var1.translateKey("selectServer.delete")));
|
||||
this.buttonList.add(this.field_96289_p = new GuiButton(7, this.width / 2 - 154 + 36, this.height - 28, 60, 20, var1.translateKey("selectServer.edit")));
|
||||
this.buttonList.add(this.buttonDelete = new GuiButton(2, this.width / 2 - 74 + 22, this.height - 28, 60, 20, var1.translateKey("selectServer.delete")));
|
||||
this.buttonList.add(this.buttonSelect = new GuiButton(1, this.width / 2 - 154, this.height - 52, 100, 20, var1.translateKey("selectServer.select")));
|
||||
this.buttonList.add(new GuiButton(4, this.width / 2 - 50, this.height - 52, 100, 20, var1.translateKey("selectServer.direct")));
|
||||
this.buttonList.add(new GuiButton(3, this.width / 2 + 4 + 50, this.height - 52, 100, 20, var1.translateKey("selectServer.add")));
|
||||
this.buttonList.add(new GuiButton(8, this.width / 2 + 4, this.height - 28, 70, 20, var1.translateKey("selectServer.refresh")));
|
||||
this.buttonList.add(new GuiButton(8, this.width / 2 + 4 + 10, this.height - 28, 60, 20, var1.translateKey("selectServer.refresh")));
|
||||
this.buttonList.add(new GuiButton(0, this.width / 2 + 4 + 76, this.height - 28, 75, 20, var1.translateKey("gui.cancel")));
|
||||
this.buttonList.add(new GuiButton(10, this.width / 2 - 154, this.height - 28, 30, 20, var1.translateKey("selectServer.lan")));
|
||||
boolean var2 = this.selectedServer >= 0 && this.selectedServer < this.serverSlotContainer.getSize();
|
||||
this.buttonSelect.enabled = var2;
|
||||
this.field_96289_p.enabled = var2;
|
||||
|
@ -193,6 +194,8 @@ public class GuiMultiplayer extends GuiScreen {
|
|||
--cooldownTimer;
|
||||
this.mc.displayGuiScreen(new GuiMultiplayer(this.parentScreen));
|
||||
}
|
||||
} else if (par1GuiButton.id == 10) {
|
||||
this.mc.displayGuiScreen(this.parentScreen);
|
||||
} else {
|
||||
this.serverSlotContainer.actionPerformed(par1GuiButton);
|
||||
}
|
||||
|
|
91
src/main/java/net/minecraft/src/GuiShareToLan.java
Normal file
91
src/main/java/net/minecraft/src/GuiShareToLan.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
import net.lax1dude.eaglercraft.IntegratedServer;
|
||||
|
||||
public class GuiShareToLan extends GuiScreen {
|
||||
/**
|
||||
* A reference to the screen object that created this. Used for navigating between screens.
|
||||
*/
|
||||
private final GuiScreen parentScreen;
|
||||
private GuiButton buttonAllowCommandsToggle;
|
||||
private GuiButton buttonGameMode;
|
||||
|
||||
/**
|
||||
* The currently selected game mode. One of 'survival', 'creative', or 'adventure'
|
||||
*/
|
||||
private String gameMode = "survival";
|
||||
|
||||
/** True if 'Allow Cheats' is currently enabled */
|
||||
private boolean allowCommands;
|
||||
|
||||
public GuiShareToLan(GuiScreen par1GuiScreen) {
|
||||
this.parentScreen = par1GuiScreen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
public void initGui() {
|
||||
this.buttonList.clear();
|
||||
this.buttonList.add(new GuiButton(101, this.width / 2 - 155, this.height - 28, 150, 20, StatCollector.translateToLocal("lanServer.start")));
|
||||
this.buttonList.add(new GuiButton(102, this.width / 2 + 5, this.height - 28, 150, 20, StatCollector.translateToLocal("gui.cancel")));
|
||||
this.buttonList.add(this.buttonGameMode = new GuiButton(104, this.width / 2 - 155, 100, 150, 20, StatCollector.translateToLocal("selectWorld.gameMode")));
|
||||
this.buttonList.add(this.buttonAllowCommandsToggle = new GuiButton(103, this.width / 2 + 5, 100, 150, 20, StatCollector.translateToLocal("selectWorld.allowCommands")));
|
||||
this.func_74088_g();
|
||||
}
|
||||
|
||||
private void func_74088_g() {
|
||||
this.buttonGameMode.displayString = StatCollector.translateToLocal("selectWorld.gameMode") + " " + StatCollector.translateToLocal("selectWorld.gameMode." + this.gameMode);
|
||||
this.buttonAllowCommandsToggle.displayString = StatCollector.translateToLocal("selectWorld.allowCommands") + " ";
|
||||
|
||||
if (this.allowCommands) {
|
||||
this.buttonAllowCommandsToggle.displayString = this.buttonAllowCommandsToggle.displayString + StatCollector.translateToLocal("options.on");
|
||||
} else {
|
||||
this.buttonAllowCommandsToggle.displayString = this.buttonAllowCommandsToggle.displayString + StatCollector.translateToLocal("options.off");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
|
||||
*/
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if (par1GuiButton.id == 102) {
|
||||
this.mc.displayGuiScreen(this.parentScreen);
|
||||
} else if (par1GuiButton.id == 104) {
|
||||
if (this.gameMode.equals("survival")) {
|
||||
this.gameMode = "creative";
|
||||
} else if (this.gameMode.equals("creative")) {
|
||||
this.gameMode = "adventure";
|
||||
} else {
|
||||
this.gameMode = "survival";
|
||||
}
|
||||
|
||||
this.func_74088_g();
|
||||
} else if (par1GuiButton.id == 103) {
|
||||
this.allowCommands = !this.allowCommands;
|
||||
this.func_74088_g();
|
||||
} else if (par1GuiButton.id == 101) {
|
||||
this.mc.displayGuiScreen((GuiScreen)null);
|
||||
String var2 = IntegratedServer.shareToLAN(EnumGameType.getByName(this.gameMode), this.allowCommands);
|
||||
String var3;
|
||||
|
||||
if (var2 != null) {
|
||||
var3 = StatCollector.translateToLocalFormatted("commands.publish.started", var2);
|
||||
} else {
|
||||
var3 = StatCollector.translateToLocal("commands.publish.failed");
|
||||
}
|
||||
|
||||
this.mc.ingameGUI.getChatGUI().printChatMessage(var3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
this.drawDefaultBackground();
|
||||
this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("lanServer.title"), this.width / 2, 50, 16777215);
|
||||
this.drawCenteredString(this.fontRenderer, StatCollector.translateToLocal("lanServer.otherPlayers"), this.width / 2, 82, 16777215);
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import org.teavm.jso.JSFunctor;
|
|||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
|
||||
public interface EaglercraftLANClient {
|
||||
public interface EaglercraftLANClient extends JSObject {
|
||||
|
||||
final int READYSTATE_INIT_FAILED = -2;
|
||||
final int READYSTATE_FAILED = -1;
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.teavm.jso.JSFunctor;
|
|||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.typedarrays.ArrayBuffer;
|
||||
|
||||
public interface EaglercraftLANServer {
|
||||
public interface EaglercraftLANServer extends JSObject {
|
||||
|
||||
boolean LANServerSupported();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user