many SP and LAN bug fixes, multi-dim TP command

This commit is contained in:
LAX1DUDE 2022-08-22 22:49:25 -07:00
parent 757ac80bbe
commit 0e11249c8e
23 changed files with 31344 additions and 31261 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -742,7 +742,7 @@ window.initializeLANServer = (() => {
if(peerId.length == 0) {
for(const thePeer of this.peerList.values()) {
if((typeof thePeer !== "undefined") && thePeer !== null) {
this.peerList.delete(thePeer);
this.peerList.delete(peerId);
try {
thePeer.disconnect();
}catch(e) {}
@ -754,7 +754,7 @@ window.initializeLANServer = (() => {
}
var thePeer = this.peerList.get(peerId);
if((typeof thePeer !== "undefined") && thePeer !== null) {
this.peerList.delete(thePeer);
this.peerList.delete(peerId);
try {
thePeer.disconnect();
}catch(e) {}
@ -762,6 +762,10 @@ window.initializeLANServer = (() => {
}
}
countPeers() {
return this.peerList.size;
}
};
window.constructLANServer = () => new EaglercraftLANServer();

View File

@ -476,6 +476,7 @@ options.framebufferAntialias.msaa4=MSAA4
options.framebufferAntialias.msaa8=MSAA8
options.patchAnisotropic=Fix ANGLE bug #4994
options.chunkUpdates=Chunk Update per FPS
options.adderall=Adderall
performance.max=Max FPS
performance.balanced=Balanced

View File

@ -334,7 +334,11 @@ public class EaglerSPRelay extends WebSocketServer {
arg0.close();
}else if(ipkt.connectionType == 0x04) {
logger.debug("[{}]: Polling the server for other worlds", (String) arg0.getAttachment());
arg0.send(IPacket.writePacket(new IPacket07LocalWorlds(getLocalWorlds(waiting.address))));
if(config.isEnableShowLocals()) {
arg0.send(IPacket.writePacket(new IPacket07LocalWorlds(getLocalWorlds(waiting.address))));
}else {
arg0.send(IPacket.writePacket(new IPacket07LocalWorlds(null)));
}
arg0.close();
}else {
logger.debug("[{}]: Unknown connection type: {}", (String) arg0.getAttachment(), ipkt.connectionType);

View File

@ -36,6 +36,7 @@ public class EaglerSPRelayConfig {
private String originWhitelist = "";
private String[] originWhitelistArray = new String[0];
private boolean enableRealIpHeader = false;
private boolean enableShowLocals = true;
private String serverComment = "Eags. Public LAN Relay";
public void load(File conf) {
@ -54,7 +55,7 @@ public class EaglerSPRelayConfig {
gotPingRateLimitLimit = false, gotPingRateLimitLockoutLimit = false,
gotPingRateLimitLockoutDuration = false;
boolean gotOriginWhitelist = false, gotEnableRealIpHeader = false,
gotAddress = false, gotComment = false;
gotAddress = false, gotComment = false, gotShowLocals = false;
Throwable t2 = null;
try(BufferedReader reader = new BufferedReader(new FileReader(conf))) {
@ -237,6 +238,16 @@ public class EaglerSPRelayConfig {
t2 = t;
break;
}
}else if(ss[0].equalsIgnoreCase("show-local-worlds")) {
try {
enableShowLocals = getBooleanValue(ss[1]);
gotShowLocals = true;
}catch(Throwable t) {
EaglerSPRelay.logger.warn("Invalid show-local-worlds {} in conf {}", ss[1], conf.getAbsoluteFile());
EaglerSPRelay.logger.warn(t);
t2 = t;
break;
}
}else if(ss[0].equalsIgnoreCase("server-comment")) {
serverComment = ss[1];
gotComment = true;
@ -259,7 +270,7 @@ public class EaglerSPRelayConfig {
!gotPingRateLimitPeriod || !gotPingRateLimitLimit ||
!gotPingRateLimitLockoutLimit || !gotPingRateLimitLockoutDuration ||
!gotOriginWhitelist || !gotEnableRealIpHeader || !gotAddress ||
!gotComment) {
!gotComment || !gotShowLocals) {
EaglerSPRelay.logger.warn("Updating config file: {}", conf.getAbsoluteFile());
save(conf);
}
@ -300,6 +311,7 @@ public class EaglerSPRelayConfig {
w.println("world-ratelimit-lockout-duration: " + openRateLimitLockoutDuration);
w.println("origin-whitelist: " + originWhitelist);
w.println("enable-real-ip-header: " + enableRealIpHeader);
w.println("show-local-worlds: " + isEnableShowLocals());
w.print("server-comment: " + serverComment);
}catch(IOException t) {
EaglerSPRelay.logger.error("Failed to write config file: {}", conf.getAbsoluteFile());
@ -433,5 +445,9 @@ public class EaglerSPRelayConfig {
}
return new String(ret);
}
public boolean isEnableShowLocals() {
return enableShowLocals;
}
}

View File

@ -25,15 +25,19 @@ public class IPacket07LocalWorlds extends IPacket {
}
public void write(DataOutputStream output) throws IOException {
int i = worldsList.size();
if(i > 255) {
i = 255;
}
output.write(i);
for(int j = 0; j < i; ++j) {
LocalWorld w = worldsList.get(j);
writeASCII8(output, w.worldName);
writeASCII8(output, w.worldCode);
if(worldsList == null) {
output.write(0);
}else {
int i = worldsList.size();
if(i > 255) {
i = 255;
}
output.write(i);
for(int j = 0; j < i; ++j) {
LocalWorld w = worldsList.get(j);
writeASCII8(output, w.worldName);
writeASCII8(output, w.worldCode);
}
}
}

View File

@ -44,12 +44,12 @@ public class CommandServerTp extends CommandBase {
throw new PlayerNotFoundException();
}
if (var11.worldObj != var3.worldObj) {
notifyAdmins(par1ICommandSender, "commands.tp.notSameDimension", new Object[0]);
return;
}
var3.mountEntity((Entity) null);
if (var11.worldObj != var3.worldObj) {
var3.travelToTheEnd(var11.dimension);
}
var3.playerNetServerHandler.setPlayerLocation(var11.posX, var11.posY, var11.posZ, var11.rotationYaw,
var11.rotationPitch);
notifyAdmins(par1ICommandSender, "commands.tp.success",

View File

@ -664,8 +664,7 @@ public class NetServerHandler extends NetHandler {
public void handleClientCommand(Packet205ClientCommand par1Packet205ClientCommand) {
if (par1Packet205ClientCommand.forceRespawn == 1) {
if (this.playerEntity.playerConqueredTheEnd) {
this.playerEntity = this.mcServer.getConfigurationManager().recreatePlayerEntity(this.playerEntity, 0,
true);
this.playerEntity = this.mcServer.getConfigurationManager().recreatePlayerEntity(this.playerEntity, 0, true, true);
} else if (this.playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled()) {
if (this.mcServer.isSinglePlayer()
&& this.playerEntity.username.equals(this.mcServer.getServerOwner())) {
@ -678,8 +677,7 @@ public class NetServerHandler extends NetHandler {
return;
}
this.playerEntity = this.mcServer.getConfigurationManager().recreatePlayerEntity(this.playerEntity, 0,
false);
this.playerEntity = this.mcServer.getConfigurationManager().recreatePlayerEntity(this.playerEntity, 0, false, true);
}
}
}

View File

@ -20,6 +20,8 @@ public class GuiScreenLANConnecting extends GuiScreen {
private NetClientHandler netHandler = null;
private int renderCount = 0;
public GuiScreenLANConnecting(GuiScreen parent, String code) {
this.parent = parent;
this.code = code;
@ -54,37 +56,39 @@ public class GuiScreenLANConnecting extends GuiScreen {
String message = st.translateKey("lanServer.pleaseWait");
this.drawString(fontRenderer, message, (this.width - this.fontRenderer.getStringWidth(message)) / 2, this.height / 3 + 10, 0xFFFFFF);
RelayServerSocket sock;
if(relay == null) {
sock = IntegratedServer.relayManager.getWorkingRelay((str) -> ls.resetProgresAndWorkingMessage("Connecting: " + str), 0x02, code);
}else {
sock = IntegratedServer.relayManager.connectHandshake(relay, 0x02, code);
}
if(sock == null) {
this.mc.displayGuiScreen(new GuiScreenNoRelays(parent, st.translateKey("noRelay.worldNotFound1").replace("$code$", code),
st.translateKey("noRelay.worldNotFound2").replace("$code$", code), st.translateKey("noRelay.worldNotFound3")));
return;
}
LANClientNetworkManager netMgr = LANClientNetworkManager.connectToWorld(sock, code, sock.getURI());
if(netMgr == null) {
this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", "noRelay.worldFail", ""));
return;
}
completed = true;
try {
netHandler = new NetClientHandler(mc, netMgr);
this.mc.setNetManager(netMgr);
netMgr.setNetHandler(netHandler);
netHandler.addToSendQueue(new Packet2ClientProtocol(61, EaglerProfile.username, "127.0.0.1", mc.gameSettings.renderDistance));
netHandler.addToSendQueue(new Packet250CustomPayload("EAG|MySkin", EaglerProfile.getSkinPacket()));
netHandler.addToSendQueue(new Packet250CustomPayload("EAG|MyCape", EaglerProfile.getCapePacket()));
} catch (IOException e) {
this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", "could not create nethandler", ""));
e.printStackTrace();
return;
if(++renderCount > 1) {
RelayServerSocket sock;
if(relay == null) {
sock = IntegratedServer.relayManager.getWorkingRelay((str) -> ls.resetProgresAndWorkingMessage("Connecting: " + str), 0x02, code);
}else {
sock = IntegratedServer.relayManager.connectHandshake(relay, 0x02, code);
}
if(sock == null) {
this.mc.displayGuiScreen(new GuiScreenNoRelays(parent, st.translateKey("noRelay.worldNotFound1").replace("$code$", code),
st.translateKey("noRelay.worldNotFound2").replace("$code$", code), st.translateKey("noRelay.worldNotFound3")));
return;
}
LANClientNetworkManager netMgr = LANClientNetworkManager.connectToWorld(sock, code, sock.getURI());
if(netMgr == null) {
this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", "noRelay.worldFail", ""));
return;
}
completed = true;
try {
netHandler = new NetClientHandler(mc, netMgr);
this.mc.setNetManager(netMgr);
netMgr.setNetHandler(netHandler);
netHandler.addToSendQueue(new Packet2ClientProtocol(61, EaglerProfile.username, "127.0.0.1", mc.gameSettings.renderDistance));
netHandler.addToSendQueue(new Packet250CustomPayload("EAG|MySkin", EaglerProfile.getSkinPacket()));
netHandler.addToSendQueue(new Packet250CustomPayload("EAG|MyCape", EaglerProfile.getCapePacket()));
} catch (IOException e) {
this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", "could not create nethandler", ""));
e.printStackTrace();
return;
}
}
}
}

View File

@ -259,7 +259,7 @@ public class IntegratedServer {
public static void processICP() {
if(!EaglerAdapter.isIntegratedServerAlive()) {
if(IntegratedServerLAN.isHostingLAN()) {
if(IntegratedServerLAN.isLANOpen()) {
IntegratedServerLAN.closeLAN();
}
return;

View File

@ -96,6 +96,10 @@ public class IntegratedServerLAN {
}
public static boolean isHostingLAN() {
return lanRelaySocket != null || EaglerAdapter.countPeers() > 0;
}
public static boolean isLANOpen() {
return lanRelaySocket != null;
}

View File

@ -1147,7 +1147,7 @@ public class Minecraft implements Runnable {
wasPaused = isGamePaused;
}
if(lanState && !IntegratedServerLAN.isHostingLAN()) {
if(lanState && !IntegratedServerLAN.isLANOpen()) {
lanState = false;
if(thePlayer != null) {
thePlayer.sendChatToPlayer(EnumChatFormatting.RED + StatCollector.translateToLocal("lanServer.relayDisconnected"));

View File

@ -8,7 +8,7 @@ public enum EnumOptions {
CHAT_VISIBILITY("options.chat.visibility", false, false), CHAT_COLOR("options.chat.color", false, true), CHAT_LINKS("options.chat.links", false, true), CHAT_OPACITY("options.chat.opacity", true, false),
CHAT_LINKS_PROMPT("options.chat.links.prompt", false, true), USE_SERVER_TEXTURES("options.serverTextures", false, true), SNOOPER_ENABLED("options.snooper", false, true), USE_FULLSCREEN("options.fullscreen", false, true),
ENABLE_FOG("options.fog", false, true), SHOW_CAPE("options.showCape", false, true), ANTIALIASING("options.framebufferAntialias", false, false), CHAT_SCALE("options.chat.scale", true, false), CHAT_WIDTH("options.chat.width", true, false),
CHAT_HEIGHT_FOCUSED("options.chat.height.focused", true, false), CHAT_HEIGHT_UNFOCUSED("options.chat.height.unfocused", true, false), CHUNK_UPDATES("options.chunkUpdates", false, false);
CHAT_HEIGHT_FOCUSED("options.chat.height.focused", true, false), CHAT_HEIGHT_UNFOCUSED("options.chat.height.unfocused", true, false), CHUNK_UPDATES("options.chunkUpdates", false, false), ADDERALL("options.adderall", false, true);
private final boolean enumFloat;
private final boolean enumBoolean;

View File

@ -87,5 +87,11 @@ class EnumOptionsHelper {
} catch (NoSuchFieldError var10) {
;
}
try {
enumOptionsMappingHelperArray[EnumOptions.ADDERALL.ordinal()] = 17;
} catch (NoSuchFieldError var10) {
;
}
}
}

View File

@ -144,6 +144,8 @@ public class GameSettings {
public boolean hideJoinCode = false;
public int relayTimeout = 4;
public boolean adderall = false;
public GameSettings(Minecraft par1Minecraft) {
this.keyBindings = new KeyBinding[] { this.keyBindAttack, this.keyBindUseItem, this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory,
@ -359,6 +361,10 @@ public class GameSettings {
this.mc.toggleFullscreen();
}
}
if (par1EnumOptions == EnumOptions.ADDERALL) {
this.adderall = !this.adderall;
}
this.saveOptions();
}
@ -418,6 +424,9 @@ public class GameSettings {
case 15:
return this.enableFog;
case 17:
return this.adderall;
default:
return false;
@ -534,6 +543,7 @@ public class GameSettings {
if(yee.hasKey("difficulty")) difficulty = yee.getByte("difficulty");
if(yee.hasKey("hideJoinCode")) hideJoinCode = yee.getBoolean("hideJoinCode");
if(yee.hasKey("relayTimeout")) relayTimeout = yee.getByte("relayTimeout");
if(yee.hasKey("adderall")) adderall = yee.getBoolean("adderall");
if(voiceListenRadius < 5) voiceListenRadius = 5;
else if(voiceListenRadius > 22) voiceListenRadius = 22;
@ -612,6 +622,7 @@ public class GameSettings {
yee.setByte("difficulty", (byte)difficulty);
yee.setBoolean("hideJoinCode", hideJoinCode);
yee.setByte("relayTimeout", (byte)relayTimeout);
yee.setBoolean("adderall", adderall);
for (int var4 = 0; var4 < this.keyBindings.length; ++var4) {
yee.setInteger(keyBindings[var4].keyDescription, keyBindings[var4].keyCode);

View File

@ -34,7 +34,7 @@ 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")));
this.buttonList.add(lanButton = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal(IntegratedServerLAN.isHostingLAN() ? "menu.closeLan" : "menu.shareToLan")));
this.buttonList.add(lanButton = new GuiButton(7, this.width / 2 + 2, this.height / 4 + 96 + var1, 98, 20, StatCollector.translateToLocal(IntegratedServerLAN.isLANOpen() ? "menu.closeLan" : "menu.shareToLan")));
lanButton.enabled = mc.isSingleplayer();
this.buttonList.add(new GuiButton(8, 3, 3, 120, 20, StatCollector.translateToLocal("menu.skinCapeSettings")));
}
@ -67,7 +67,7 @@ public class GuiIngameMenu extends GuiScreen {
break;
case 7:
if (IntegratedServerLAN.isHostingLAN()) {
if (IntegratedServerLAN.isLANOpen()) {
this.mc.lanState = false;
IntegratedServerLAN.closeLAN();
IntegratedServer.configureLAN(this.mc.theWorld.getWorldInfo().getGameType(), false);
@ -118,7 +118,7 @@ public class GuiIngameMenu extends GuiScreen {
drawString(fontRenderer, "Eaglercraft: " + ConfigConstants.version, 6, 27, 0x999999);
if(IntegratedServerLAN.isHostingLAN()) {
if(IntegratedServerLAN.isLANOpen()) {
String str = var1.translateKey("lanServer.pauseMenu0");
drawString(fontRenderer, str, 6, 52, 0xFFFF55);

View File

@ -6,8 +6,10 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
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;
@ -239,8 +241,30 @@ public class GuiSelectWorld extends GuiScreen {
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.

View File

@ -3926,4 +3926,8 @@ public class EaglerAdapterImpl2 {
rtcLANServer.signalRemoteDisconnect(peer);
}
public static final int countPeers() {
return rtcLANServer.countPeers();
}
}

View File

@ -47,6 +47,8 @@ public interface EaglercraftLANServer extends JSObject {
void signalRemoteICECandidate(String peerId, String candidate);
void signalRemoteDisconnect(String peerId);
int countPeers();
@JSFunctor
public static interface ICECandidateHandler extends JSObject {