Fix multiplayer
This commit is contained in:
parent
e2a7989070
commit
af16d25537
File diff suppressed because one or more lines are too long
|
@ -18,10 +18,11 @@ public class GameSettings {
|
|||
File file1 = new File("filesystem");
|
||||
File file = new File(file1, "options.txt");
|
||||
if(!file.exists()) {
|
||||
file.createNewFile();
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] fileData = new byte[0];
|
||||
byte[] fileData = new byte[(int) file.length()];
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
fis.read(fileData);
|
||||
} catch(IOException e) {
|
||||
|
@ -92,6 +93,10 @@ public class GameSettings {
|
|||
if(var3[0].equals("lastServer")) {
|
||||
Minecraft.getMinecraft().gameSettings.field_12259_z = var3[1];
|
||||
}
|
||||
|
||||
if(var3[0].equals("username")) {
|
||||
Minecraft.getMinecraft().gameSettings.username = var3[1];
|
||||
}
|
||||
|
||||
for(int var4 = 0; var4 < Minecraft.getMinecraft().gameSettings.keyBindings.length; ++var4) {
|
||||
if(var3[0].equals("key_" + Minecraft.getMinecraft().gameSettings.keyBindings[var4].keyDescription)) {
|
||||
|
@ -124,6 +129,12 @@ public class GameSettings {
|
|||
var1.println("difficulty:" + Minecraft.getMinecraft().gameSettings.difficulty);
|
||||
var1.println("fancyGraphics:" + Minecraft.getMinecraft().gameSettings.fancyGraphics);
|
||||
var1.println("skin:" + Minecraft.getMinecraft().gameSettings.skin);
|
||||
if(Minecraft.getMinecraft().gameSettings.field_12259_z.length() != 0) {
|
||||
var1.println("lastServer:" + Minecraft.getMinecraft().gameSettings.field_12259_z);
|
||||
}
|
||||
if(Minecraft.getMinecraft().gameSettings.username.length() != 0) {
|
||||
var1.println("username:" + Minecraft.getMinecraft().gameSettings.username);
|
||||
}
|
||||
|
||||
for(int var2 = 0; var2 < Minecraft.getMinecraft().gameSettings.keyBindings.length; ++var2) {
|
||||
var1.println("key_" + Minecraft.getMinecraft().gameSettings.keyBindings[var2].keyDescription + ":" + Minecraft.getMinecraft().gameSettings.keyBindings[var2].keyCode);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.lax1dude.eaglercraft;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import net.PeytonPlayz585.opengl.GL11;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.Session;
|
||||
|
|
|
@ -71,9 +71,7 @@ import org.lwjgl.util.glu.GLU;
|
|||
import net.lax1dude.eaglercraft.AssetRepository;
|
||||
import net.lax1dude.eaglercraft.EaglerImage;
|
||||
import net.lax1dude.eaglercraft.GameWindowListener;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.NetClientHandler;
|
||||
|
||||
public class EaglerAdapterImpl2 {
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ public class ChunkLoader implements IChunkLoader {
|
|||
}
|
||||
|
||||
private File chunkFileForXZ(int i, int j) {
|
||||
if(saveDir == null) {
|
||||
return null;
|
||||
}
|
||||
String s = (new StringBuilder()).append("c.").append(Integer.toString(i, 36)).append(".").append(Integer.toString(j, 36)).append(".dat").toString();
|
||||
String s1 = Integer.toString(i & 0x3f, 36);
|
||||
String s2 = Integer.toString(j & 0x3f, 36);
|
||||
|
@ -44,6 +47,9 @@ public class ChunkLoader implements IChunkLoader {
|
|||
}
|
||||
|
||||
public Chunk loadChunk(World world, int i, int j) {
|
||||
if(saveDir == null) {
|
||||
return null;
|
||||
}
|
||||
File file = chunkFileForXZ(i, j);
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
|
@ -78,6 +84,9 @@ public class ChunkLoader implements IChunkLoader {
|
|||
}
|
||||
|
||||
public void saveChunk(World world, Chunk chunk) {
|
||||
if(saveDir == null) {
|
||||
return;
|
||||
}
|
||||
world.func_663_l();
|
||||
File file = chunkFileForXZ(chunk.xPosition, chunk.zPosition);
|
||||
if (file.exists()) {
|
||||
|
|
|
@ -118,7 +118,8 @@ public class Minecraft implements Runnable {
|
|||
public void startGame() {
|
||||
|
||||
RenderManager.instance.field_4236_f = new ItemRenderer(this);
|
||||
this.gameSettings = new GameSettings(this);
|
||||
new GameSettings(this);
|
||||
this.gameSettings.loadOptions();
|
||||
this.texturePackList = new TexturePackList(this);
|
||||
this.renderEngine = new RenderEngine(texturePackList, this.gameSettings);
|
||||
this.fontRenderer = new FontRenderer(this.gameSettings, "/font/default.png", this.renderEngine);
|
||||
|
@ -276,6 +277,12 @@ public class Minecraft implements Runnable {
|
|||
|
||||
try {
|
||||
this.runTick();
|
||||
} catch(ArrayIndexOutOfBoundsException e) {
|
||||
if(this.isMultiplayerWorld()) {
|
||||
continue;
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (MinecraftException var14) {
|
||||
this.theWorld = null;
|
||||
this.func_6261_a((World)null);
|
||||
|
@ -313,7 +320,15 @@ public class Minecraft implements Runnable {
|
|||
this.field_6327_b.func_6467_a(this.timer.renderPartialTicks);
|
||||
}
|
||||
|
||||
this.field_9243_r.func_4136_b(this.timer.renderPartialTicks);
|
||||
try {
|
||||
this.field_9243_r.func_4136_b(this.timer.renderPartialTicks);
|
||||
} catch(ArrayIndexOutOfBoundsException e) {
|
||||
if(this.isMultiplayerWorld()) {
|
||||
continue;
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!GL11.isFocused()) {
|
||||
|
@ -437,7 +452,7 @@ public class Minecraft implements Runnable {
|
|||
|
||||
public void shutdown() {
|
||||
System.out.println("Stopping!");
|
||||
if(this.theWorld != null && !this.theWorld.multiplayerWorld) {
|
||||
if(this.theWorld != null && !this.isMultiplayerWorld()) {
|
||||
this.theWorld.saveLevel();
|
||||
this.theWorld.chunkProvider.saveChunks(false, (IProgressUpdate)null);
|
||||
}
|
||||
|
@ -625,17 +640,6 @@ public class Minecraft implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
//Fix for chunks not rendering in multiplayer after player respawn
|
||||
if(respawnTimer > 0) {
|
||||
respawnTimer--;
|
||||
|
||||
if(respawnTimer == 0 && this.theWorld != null) {
|
||||
if(this.theWorld.multiplayerWorld) {
|
||||
field_6323_f.func_958_a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.ingameGUI.func_555_a();
|
||||
this.field_9243_r.func_910_a(1.0F);
|
||||
if(this.thePlayer != null) {
|
||||
|
@ -725,6 +729,10 @@ public class Minecraft implements Runnable {
|
|||
if(Keyboard.getEventKey() == this.gameSettings.keyBindDrop.keyCode) {
|
||||
this.thePlayer.dropPlayerItemWithRandomChoice(this.thePlayer.inventory.decrStackSize(this.thePlayer.inventory.currentItem, 1), false);
|
||||
}
|
||||
|
||||
if(this.isMultiplayerWorld() && Keyboard.getEventKey() == this.gameSettings.keyBindChat.keyCode) {
|
||||
this.displayGuiScreen(new GuiChat());
|
||||
}
|
||||
}
|
||||
|
||||
for(int var4 = 0; var4 < 9; ++var4) {
|
||||
|
@ -736,10 +744,6 @@ public class Minecraft implements Runnable {
|
|||
if(Keyboard.getEventKey() == this.gameSettings.keyBindToggleFog.keyCode) {
|
||||
this.gameSettings.setOptionValue(4, !Keyboard.isKeyDown(42) && !Keyboard.isKeyDown(54) ? 1 : -1);
|
||||
}
|
||||
|
||||
if(this.isMultiplayerWorld() && Keyboard.getEventKey() == this.gameSettings.keyBindChat.keyCode) {
|
||||
this.displayGuiScreen(new GuiChat());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1003,12 +1007,10 @@ public class Minecraft implements Runnable {
|
|||
if(this.currentScreen instanceof GuiGameOver) {
|
||||
this.displayGuiScreen((GuiScreen)null);
|
||||
}
|
||||
respawnTimer = 5;
|
||||
|
||||
}
|
||||
|
||||
public static Minecraft getMinecraft() {
|
||||
return mc;
|
||||
}
|
||||
|
||||
private int respawnTimer;
|
||||
}
|
||||
|
|
|
@ -270,18 +270,12 @@ public class Chunk {
|
|||
|
||||
this.data.setNibble(var1, var2, var3, var5);
|
||||
if(!this.worldObj.worldProvider.field_6478_e) {
|
||||
if(!(var6 < 0 || var6 > 256)) {
|
||||
if(Block.lightOpacity[var6] != 0) {
|
||||
if(var2 >= var7) {
|
||||
this.func_1003_g(var1, var2 + 1, var3);
|
||||
}
|
||||
} else if(var2 == var7 - 1) {
|
||||
this.func_1003_g(var1, var2, var3);
|
||||
}
|
||||
} else {
|
||||
if(var2 == var7 - 1) {
|
||||
this.func_1003_g(var1, var2, var3);
|
||||
if(Block.lightOpacity[var6] != 0) {
|
||||
if(var2 >= var7) {
|
||||
this.func_1003_g(var1, var2 + 1, var3);
|
||||
}
|
||||
} else if(var2 == var7 - 1) {
|
||||
this.func_1003_g(var1, var2, var3);
|
||||
}
|
||||
|
||||
this.worldObj.func_616_a(EnumSkyBlock.Sky, var9, var2, var10, var9, var2, var10);
|
||||
|
@ -289,7 +283,7 @@ public class Chunk {
|
|||
|
||||
this.worldObj.func_616_a(EnumSkyBlock.Block, var9, var2, var10, var9, var2, var10);
|
||||
this.func_996_c(var1, var3);
|
||||
if(var4 != 0 && !(var4 < 0 || var4 > 256)) {
|
||||
if(var4 != 0) {
|
||||
Block.blocksList[var4].onBlockAdded(this.worldObj, var9, var2, var10);
|
||||
}
|
||||
|
||||
|
|
|
@ -117,11 +117,11 @@ public class ChunkCache implements IBlockAccess {
|
|||
}
|
||||
|
||||
public boolean isBlockOpaqueCube(int var1, int var2, int var3) {
|
||||
if(this.getBlockId(var1, var2, var3) < 0 || this.getBlockId(var1, var2, var3) > 256) {
|
||||
return false;
|
||||
if(!(this.getBlockId(var1, var2, var3) < 0)) {
|
||||
Block var4 = Block.blocksList[this.getBlockId(var1, var2, var3)];
|
||||
return var4 == null ? false : var4.isOpaqueCube();
|
||||
}
|
||||
Block var4 = Block.blocksList[this.getBlockId(var1, var2, var3)];
|
||||
return var4 == null ? false : var4.isOpaqueCube();
|
||||
return false;
|
||||
}
|
||||
|
||||
public WorldChunkManager func_4075_a() {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class GameSettings {
|
|||
|
||||
public GameSettings(Minecraft var1) {
|
||||
this.mc = var1;
|
||||
this.loadOptions();
|
||||
this.mc.gameSettings = this;
|
||||
}
|
||||
|
||||
public GameSettings() {
|
||||
|
@ -190,14 +190,14 @@ public class GameSettings {
|
|||
if(var3[0].equals("skin")) {
|
||||
this.skin = var3[1];
|
||||
}
|
||||
|
||||
if(var3[0].equals("lastServer")) {
|
||||
this.field_12259_z = var3[1];
|
||||
}
|
||||
|
||||
if(var3[0].equals("username")) {
|
||||
this.username = var3[1];
|
||||
}
|
||||
|
||||
if(var3[0].equals("lastServer")) {
|
||||
this.field_12259_z = var3[1];
|
||||
}
|
||||
|
||||
for(int var4 = 0; var4 < this.keyBindings.length; ++var4) {
|
||||
if(var3[0].equals("key_" + this.keyBindings[var4].keyDescription)) {
|
||||
|
|
|
@ -1,79 +1,21 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.PeytonPlayz585.opengl.GL11;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class GuiConnecting extends GuiScreen {
|
||||
private NetClientHandler clientHandler;
|
||||
private boolean cancelled = false;
|
||||
String uri;
|
||||
private int timer = 0;
|
||||
|
||||
public GuiConnecting(Minecraft var1, String var2, int var3) {
|
||||
cancelled = false;
|
||||
uri = var2 + ":" + var3;
|
||||
public GuiConnecting(Minecraft var1, String var2) {
|
||||
var1.func_6261_a((World)null);
|
||||
(new ThreadConnectToServer(this, var1, var2)).start();
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
if (timer > 2 && this.clientHandler == null) {
|
||||
try {
|
||||
String uria = null;
|
||||
if(uri.startsWith("ws://")) {
|
||||
uria = uri.substring(5);
|
||||
}else if(uri.startsWith("wss://")){
|
||||
uria = uri.substring(6);
|
||||
}else if(!uri.contains("://")){
|
||||
uria = uri;
|
||||
uri = "ws://" + uri;
|
||||
}else {
|
||||
this.mc.displayGuiScreen(new GuiConnectFailed("disconnect.genericReason", "invalid uri websocket protocol"));
|
||||
return;
|
||||
}
|
||||
|
||||
int i = uria.lastIndexOf(':');
|
||||
int port = -1;
|
||||
|
||||
if(i > 0 && uria.startsWith("[") && uria.charAt(i - 1) != ']') {
|
||||
i = -1;
|
||||
}
|
||||
|
||||
if(i == -1) port = uri.startsWith("wss") ? 443 : 80;
|
||||
if(uria.endsWith("/")) uria = uria.substring(0, uria.length() - 1);
|
||||
|
||||
if(port == -1) {
|
||||
try {
|
||||
int i2 = uria.indexOf('/');
|
||||
port = Integer.parseInt(uria.substring(i + 1, i2 == -1 ? uria.length() : i2 - 1));
|
||||
}catch(Throwable t) {
|
||||
this.mc.displayGuiScreen(new GuiConnectFailed("disconnect.genericReason", "invalid port number"));
|
||||
}
|
||||
}
|
||||
|
||||
this.clientHandler = new NetClientHandler(mc, uri, 0);
|
||||
this.clientHandler.addToSendQueue(new Packet2Handshake(mc.field_6320_i.inventory));
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
this.clientHandler.disconnect();
|
||||
}catch(Throwable t) {
|
||||
}
|
||||
e.printStackTrace();
|
||||
this.mc.displayGuiScreen(new GuiConnectFailed("disconnect.genericReason", e.toString()));
|
||||
}
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.processReadPackets();
|
||||
}
|
||||
if(timer >= 1) {
|
||||
++timer;
|
||||
}
|
||||
if(timer > 5) {
|
||||
if(!GL11.connectionOpen() && this.mc.currentScreen == this) {
|
||||
this.mc.displayGuiScreen(new GuiConnectFailed("connect.failed", "disconnect.timeout"));
|
||||
}
|
||||
if(this.clientHandler != null) {
|
||||
this.clientHandler.processReadPackets();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void keyTyped(char var1, int var2) {
|
||||
|
@ -97,9 +39,6 @@ public class GuiConnecting extends GuiScreen {
|
|||
}
|
||||
|
||||
public void drawScreen(int var1, int var2, float var3) {
|
||||
if(timer == 0) {
|
||||
timer = 1;
|
||||
}
|
||||
this.drawDefaultBackground();
|
||||
if(this.clientHandler == null) {
|
||||
this.drawCenteredString(this.fontRenderer, "Connecting to the server...", this.width / 2, this.height / 2 - 50, 16777215);
|
||||
|
|
|
@ -15,7 +15,7 @@ public class GuiIngameMenu extends GuiScreen {
|
|||
if(this.mc.isMultiplayerWorld()) {
|
||||
((GuiButton)this.controlList.get(0)).displayString = "Disconnect";
|
||||
}
|
||||
|
||||
|
||||
this.controlList.add(new GuiButton(4, this.width / 2 - 100, this.height / 4 + 24, "Back to game"));
|
||||
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96, "Options..."));
|
||||
}
|
||||
|
@ -49,14 +49,12 @@ public class GuiIngameMenu extends GuiScreen {
|
|||
|
||||
public void drawScreen(int var1, int var2, float var3) {
|
||||
this.drawDefaultBackground();
|
||||
if(!this.mc.theWorld.multiplayerWorld) {
|
||||
boolean var4 = !this.mc.theWorld.func_650_a(this.updateCounter2++);
|
||||
if(var4 || this.updateCounter < 20) {
|
||||
float var5 = ((float)(this.updateCounter % 10) + var3) / 10.0F;
|
||||
var5 = MathHelper.sin(var5 * (float)Math.PI * 2.0F) * 0.2F + 0.8F;
|
||||
int var6 = (int)(255.0F * var5);
|
||||
this.drawString(this.fontRenderer, "Saving level..", 8, this.height - 16, var6 << 16 | var6 << 8 | var6);
|
||||
}
|
||||
boolean var4 = !this.mc.theWorld.func_650_a(this.updateCounter2++);
|
||||
if(var4 || this.updateCounter < 20) {
|
||||
float var5 = ((float)(this.updateCounter % 10) + var3) / 10.0F;
|
||||
var5 = MathHelper.sin(var5 * (float)Math.PI * 2.0F) * 0.2F + 0.8F;
|
||||
int var6 = (int)(255.0F * var5);
|
||||
this.drawString(this.fontRenderer, "Saving level..", 8, this.height - 16, var6 << 16 | var6 << 8 | var6);
|
||||
}
|
||||
|
||||
this.drawCenteredString(this.fontRenderer, "Game menu", this.width / 2, 40, 16777215);
|
||||
|
|
|
@ -76,6 +76,9 @@ public class GuiMainMenu extends GuiScreen {
|
|||
this.controlList.add(new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, "Multiplayer"));
|
||||
this.controlList.add(new GuiButton(3, this.width / 2 - 100, this.height / 4 + 96, "Mods and Texture Packs"));
|
||||
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 120 + 12, "Options..."));
|
||||
if(this.mc.field_6320_i == null) {
|
||||
((GuiButton)this.controlList.get(1)).enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton var1) {
|
||||
|
|
|
@ -27,7 +27,8 @@ public class GuiMultiplayer extends GuiScreen {
|
|||
this.controlList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, "Connect"));
|
||||
this.controlList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, "Cancel"));
|
||||
this.serverAddress = this.mc.gameSettings.field_12259_z.replaceAll("_", ":");
|
||||
((GuiButton)this.controlList.get(0)).enabled = this.serverAddress.length() > 0;
|
||||
this.username = this.mc.gameSettings.username;
|
||||
((GuiButton)this.controlList.get(0)).enabled = this.serverAddress.length() > 0 && this.username.length() > 0 && !this.serverAddress.isBlank() && !this.username.isBlank() && !this.serverAddress.isEmpty() && !this.username.isEmpty();
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton var1) {
|
||||
|
@ -40,7 +41,7 @@ public class GuiMultiplayer extends GuiScreen {
|
|||
this.mc.gameSettings.username = this.username;
|
||||
this.mc.gameSettings.saveOptions();
|
||||
String[] var2 = this.serverAddress.split(":");
|
||||
this.mc.displayGuiScreen(new GuiConnecting(this.mc, var2[0], var2.length > 1 ? this.func_4067_a(var2[1], 25565) : 25565));
|
||||
this.mc.displayGuiScreen(new GuiConnecting(this.mc, serverAddress));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,7 +77,7 @@ public class GuiMultiplayer extends GuiScreen {
|
|||
protected void keyTyped(char var1, int var2) {
|
||||
if(this.serverTextBox) {
|
||||
if(var1 == 22) {
|
||||
String var3 = GuiScreen.getClipboardString();
|
||||
String var3 = null;
|
||||
if(var3 == null) {
|
||||
var3 = "";
|
||||
}
|
||||
|
@ -106,11 +107,9 @@ public class GuiMultiplayer extends GuiScreen {
|
|||
((GuiButton)this.controlList.get(0)).enabled = this.serverAddress.length() > 0 && this.username.length() > 0 && !this.serverAddress.isBlank() && !this.username.isBlank() && !this.serverAddress.isEmpty() && !this.username.isEmpty();
|
||||
} else if(this.usernameTextBox) {
|
||||
if(var1 == 22) {
|
||||
String var3 = GuiScreen.getClipboardString();
|
||||
String var3 = null;
|
||||
if(var3 == null) {
|
||||
var3 = "";
|
||||
} else {
|
||||
var3.replaceAll("[^a-zA-Z0-9]", "");
|
||||
}
|
||||
|
||||
int var4 = 16 - this.username.length();
|
||||
|
@ -178,4 +177,4 @@ public class GuiMultiplayer extends GuiScreen {
|
|||
private boolean containsOnlyAZ09(String input) {
|
||||
return input.matches("[a-z0-9]+") || input.matches("[A-Z0-9]+");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -144,8 +144,4 @@ public class GuiScreen extends Gui {
|
|||
|
||||
public void deleteWorld(boolean var1, int var2) {
|
||||
}
|
||||
|
||||
public static String getClipboardString() {
|
||||
return GL11.getClipboard();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,12 +33,7 @@ public class MetadataChunkBlock {
|
|||
int var9 = var1.getSavedLightValue(this.field_1299_a, var6, var8, var7);
|
||||
boolean var10 = false;
|
||||
int var11 = var1.getBlockId(var6, var8, var7);
|
||||
int var12;
|
||||
if(!(var11 < 0 || var11 > 256)) {
|
||||
var12 = Block.lightOpacity[var11];
|
||||
} else {
|
||||
var12 = 0;
|
||||
}
|
||||
int var12 = Block.lightOpacity[var11];
|
||||
if(var12 == 0) {
|
||||
var12 = 1;
|
||||
}
|
||||
|
|
|
@ -7,22 +7,21 @@ import net.minecraft.client.Minecraft;
|
|||
|
||||
public class NetClientHandler extends NetHandler {
|
||||
private boolean disconnected = false;
|
||||
public static NetworkManager netManager;
|
||||
private NetworkManager netManager;
|
||||
public String field_1209_a;
|
||||
private Minecraft mc;
|
||||
private WorldClient worldClient;
|
||||
private boolean field_1210_g = false;
|
||||
Random rand = new Random();
|
||||
|
||||
public NetClientHandler(Minecraft var1, String var2, int var3) throws IOException, UnknownHostException {
|
||||
public NetClientHandler(Minecraft var1, String var2) throws IOException, UnknownHostException {
|
||||
this.mc = var1;
|
||||
String ip = var2;
|
||||
this.netManager = new NetworkManager(ip, this);
|
||||
this.netManager = new NetworkManager(var2, this);
|
||||
}
|
||||
|
||||
public void processReadPackets() {
|
||||
if(!this.disconnected) {
|
||||
this.netManager.processReadPackets();
|
||||
this.netManager.readPacket();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -16,67 +15,86 @@ import java.util.List;
|
|||
import net.PeytonPlayz585.opengl.GL11;
|
||||
|
||||
public class NetworkManager {
|
||||
|
||||
private NetHandler netHandler;
|
||||
private String serverURI;
|
||||
|
||||
private Object sendQueueLock = new Object();
|
||||
private boolean isRunning = true;
|
||||
private List dataPackets = Collections.synchronizedList(new ArrayList());
|
||||
private List chunkDataPackets = Collections.synchronizedList(new ArrayList());
|
||||
private NetHandler netHandler;
|
||||
private boolean isServerTerminating = false;
|
||||
private boolean isTerminating = false;
|
||||
private String terminationReason = "";
|
||||
private int timeSinceLastRead = 0;
|
||||
private int sendQueueByteLength = 0;
|
||||
private int chunkDataSendCounter = 0;
|
||||
public static int numWriteThreads;
|
||||
private Thread writeThread;
|
||||
|
||||
public NetworkManager(String uri, NetHandler netHandler) throws IOException {
|
||||
this.serverURI = uri;
|
||||
this.netHandler = netHandler;
|
||||
if(!GL11.startConnection(uri)) {
|
||||
throw new IOException("websocket to "+uri+" failed");
|
||||
|
||||
public NetworkManager(String var4, NetHandler var3) throws IOException {
|
||||
this.netHandler = var3;
|
||||
String uri = null;
|
||||
System.out.println(uri);
|
||||
if(var4.startsWith("ws://")) {
|
||||
uri = var4.substring(5);
|
||||
}else if(var4.startsWith("wss://")){
|
||||
uri = var4.substring(6);
|
||||
}else if(!var4.contains("://")){
|
||||
uri = var4;
|
||||
var4 = "ws://" + var4;
|
||||
}else {
|
||||
throw new IOException("Invalid URI Protocol!");
|
||||
}
|
||||
if(!GL11.startConnection(var4)) {
|
||||
//if(!GL11.startConnection(uri)) {
|
||||
throw new IOException("Websocket to " + uri + " failed!");
|
||||
//}
|
||||
}
|
||||
GL11.setDebugVar("minecraftServer", uri);
|
||||
this.writeThread = new NetworkWriterThread(this, uri + " write thread");
|
||||
this.writeThread.start();
|
||||
}
|
||||
|
||||
public void setNetHandler(NetHandler netHandler) {
|
||||
this.netHandler = netHandler;
|
||||
}
|
||||
|
||||
|
||||
public void addToSendQueue(Packet var1) {
|
||||
if(this.isSocketOpen()) {
|
||||
this.sendQueueByteLength += var1.getPacketSize() + 1;
|
||||
if(var1.isChunkDataPacket) {
|
||||
this.chunkDataPackets.add(var1);
|
||||
} else {
|
||||
this.dataPackets.add(var1);
|
||||
if(!this.isServerTerminating) {
|
||||
Object var2 = this.sendQueueLock;
|
||||
synchronized(var2) {
|
||||
this.sendQueueByteLength += var1.getPacketSize() + 1;
|
||||
if(var1.isChunkDataPacket) {
|
||||
this.chunkDataPackets.add(var1);
|
||||
} else {
|
||||
this.dataPackets.add(var1);
|
||||
}
|
||||
this.sendPacket();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ByteArrayOutputStream sendBuffer = new ByteArrayOutputStream();
|
||||
|
||||
private ByteArrayOutputStream sendBuffer;
|
||||
|
||||
private void sendPacket() {
|
||||
try {
|
||||
sendBuffer.reset();
|
||||
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
||||
boolean var1 = true;
|
||||
Packet var2;
|
||||
Object var3;
|
||||
if(!this.dataPackets.isEmpty()) {
|
||||
var1 = false;
|
||||
var2 = (Packet)this.dataPackets.remove(0);
|
||||
this.sendQueueByteLength -= var2.getPacketSize() + 1;
|
||||
var3 = this.sendQueueLock;
|
||||
synchronized(var3) {
|
||||
var2 = (Packet)this.dataPackets.remove(0);
|
||||
this.sendQueueByteLength -= var2.getPacketSize() + 1;
|
||||
}
|
||||
|
||||
sendBuffer = new ByteArrayOutputStream();
|
||||
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
||||
Packet.writePacket(var2, yee);
|
||||
GL11.writePacket(sendBuffer.toByteArray());
|
||||
}
|
||||
|
||||
sendBuffer.reset();
|
||||
DataOutputStream yee2 = new DataOutputStream(sendBuffer);
|
||||
if((var1 || this.chunkDataSendCounter-- <= 0) && !this.chunkDataPackets.isEmpty()) {
|
||||
var1 = false;
|
||||
var2 = (Packet)this.chunkDataPackets.remove(0);
|
||||
this.sendQueueByteLength -= var2.getPacketSize() + 1;
|
||||
Packet.writePacket(var2, yee2);
|
||||
var3 = this.sendQueueLock;
|
||||
synchronized(var3) {
|
||||
var2 = (Packet)this.chunkDataPackets.remove(0);
|
||||
this.sendQueueByteLength -= var2.getPacketSize() + 1;
|
||||
}
|
||||
|
||||
sendBuffer = new ByteArrayOutputStream();
|
||||
DataOutputStream yee = new DataOutputStream(sendBuffer);
|
||||
Packet.writePacket(var2, yee);
|
||||
GL11.writePacket(sendBuffer.toByteArray());
|
||||
this.chunkDataSendCounter = 50;
|
||||
}
|
||||
|
@ -86,39 +104,21 @@ public class NetworkManager {
|
|||
}
|
||||
} catch (InterruptedException var8) {
|
||||
} catch (Exception var9) {
|
||||
if(this.isSocketOpen()) {
|
||||
GL11.endConnection();
|
||||
var9.printStackTrace();
|
||||
if(!this.isTerminating) {
|
||||
this.onNetworkError(var9);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public void processReadPackets() {
|
||||
// if(this.sendQueueByteLength > 1048576) {
|
||||
// this.networkShutdown("Send buffer overflow");
|
||||
// }
|
||||
//
|
||||
// if(this.readPackets.isEmpty()) {
|
||||
// if(this.timeSinceLastRead++ == 1200) {
|
||||
// this.networkShutdown("Timed out");
|
||||
// }
|
||||
// } else {
|
||||
// this.timeSinceLastRead = 0;
|
||||
// }
|
||||
//
|
||||
// int var1 = 100;
|
||||
//
|
||||
// while(!this.readPackets.isEmpty() && var1-- >= 0) {
|
||||
// Packet var2 = (Packet)this.readPackets.remove(0);
|
||||
// var2.processPacket(this.netHandler);
|
||||
// }
|
||||
// }
|
||||
|
||||
private ByteBuffer oldChunkBuffer = null;
|
||||
private LinkedList<ByteBuffer> readChunks = new LinkedList();
|
||||
|
||||
public void processReadPackets() {
|
||||
|
||||
public void readPacket() {
|
||||
if(this.sendQueueByteLength > 1048576) {
|
||||
this.networkShutdown("Send buffer overflow");
|
||||
}
|
||||
|
||||
readChunks.clear();
|
||||
|
||||
if(oldChunkBuffer != null) {
|
||||
|
@ -130,6 +130,7 @@ public class NetworkManager {
|
|||
readChunks.add(ByteBuffer.wrap(packet));
|
||||
}
|
||||
if(!readChunks.isEmpty()) {
|
||||
this.timeSinceLastRead = 0;
|
||||
int cap = 0;
|
||||
for(ByteBuffer b : readChunks) {
|
||||
cap += b.limit();
|
||||
|
@ -142,17 +143,25 @@ public class NetworkManager {
|
|||
stream.flip();
|
||||
|
||||
DataInputStream packetStream = new DataInputStream(new ByteBufferDirectInputStream(stream));
|
||||
//int var1 = 100;
|
||||
while(stream.hasRemaining()) {
|
||||
stream.mark();
|
||||
try {
|
||||
Packet pkt = Packet.readPacket(packetStream);
|
||||
if(pkt == null) {
|
||||
this.networkShutdown("End of Stream");
|
||||
}
|
||||
pkt.processPacket(this.netHandler);
|
||||
} catch (EOFException e) {
|
||||
stream.reset();
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
continue;
|
||||
} catch (Throwable e2) {
|
||||
} catch(ArrayIndexOutOfBoundsException e) {
|
||||
continue;
|
||||
} catch(NullPointerException e) {
|
||||
continue;
|
||||
} catch(Throwable e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -163,46 +172,48 @@ public class NetworkManager {
|
|||
oldChunkBuffer = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
if(this.timeSinceLastRead++ == 1200) {
|
||||
this.networkShutdown("Timed out");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void serverShutdown() {
|
||||
if(GL11.connectionOpen()) {
|
||||
GL11.endConnection();
|
||||
GL11.setDebugVar("minecraftServer", "null");
|
||||
|
||||
if(this.isTerminating && this.readChunks.isEmpty()) {
|
||||
this.netHandler.handleErrorMessage(this.terminationReason);
|
||||
}
|
||||
}
|
||||
|
||||
public int packetSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void networkShutdown(String var1, Object... var2) {
|
||||
serverShutdown();
|
||||
}
|
||||
|
||||
public void closeConnections() {
|
||||
if(GL11.connectionOpen()) {
|
||||
GL11.endConnection();
|
||||
GL11.setDebugVar("minecraftServer", "null");
|
||||
}
|
||||
}
|
||||
|
||||
public String getServerURI() {
|
||||
return this.serverURI;
|
||||
}
|
||||
|
||||
public boolean isSocketOpen() {
|
||||
return GL11.connectionOpen();
|
||||
private void onNetworkError(Exception var1) {
|
||||
var1.printStackTrace();
|
||||
this.networkShutdown("Internal exception: " + var1.toString());
|
||||
}
|
||||
|
||||
|
||||
public void networkShutdown(String var1) {
|
||||
if(this.isRunning) {
|
||||
this.isTerminating = true;
|
||||
this.terminationReason = var1;
|
||||
this.isRunning = false;
|
||||
if(GL11.connectionOpen()) {
|
||||
GL11.endConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isRunning(NetworkManager var0) {
|
||||
return var0.isRunning;
|
||||
}
|
||||
|
||||
static boolean isServerTerminating(NetworkManager var0) {
|
||||
return var0.isServerTerminating;
|
||||
}
|
||||
|
||||
static void readNetworkPacket(NetworkManager var0) {
|
||||
var0.readPacket();
|
||||
}
|
||||
|
||||
static void sendNetworkPacket(NetworkManager var0) {
|
||||
var0.sendPacket();
|
||||
}
|
||||
|
||||
public static boolean isRunning(NetworkManager netManager) {
|
||||
return netManager.isSocketOpen();
|
||||
}
|
||||
|
||||
private static class ByteBufferDirectInputStream extends InputStream {
|
||||
private ByteBuffer buf;
|
||||
|
@ -220,4 +231,4 @@ public class NetworkManager {
|
|||
return buf.remaining();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
class NetworkWriterThread extends Thread {
|
||||
final NetworkManager netManager;
|
||||
|
||||
NetworkWriterThread(NetworkManager var1, String var2) {
|
||||
super(var2);
|
||||
this.netManager = var1;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
++NetworkManager.numWriteThreads;
|
||||
while(true) {
|
||||
boolean var11 = false;
|
||||
|
||||
try {
|
||||
var11 = true;
|
||||
if(!NetworkManager.isRunning(this.netManager)) {
|
||||
var11 = false;
|
||||
break;
|
||||
}
|
||||
|
||||
NetworkManager.sendNetworkPacket(this.netManager);
|
||||
} finally {
|
||||
if(var11) {
|
||||
--NetworkManager.numWriteThreads;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--NetworkManager.numWriteThreads;
|
||||
}
|
||||
}
|
|
@ -24,19 +24,7 @@ public class Packet5PlayerInventory extends Packet {
|
|||
public void readPacketData(DataInputStream var1) throws IOException {
|
||||
this.type = var1.readInt();
|
||||
short var2 = var1.readShort();
|
||||
ItemStack[] stacks2 = this.stacks;
|
||||
try {
|
||||
this.stacks = new ItemStack[var2];
|
||||
} catch(NegativeArraySizeException e) {
|
||||
this.stacks = stacks2;
|
||||
return;
|
||||
} catch(IndexOutOfBoundsException e) {
|
||||
this.stacks = stacks2;
|
||||
return;
|
||||
} catch(Exception e) {
|
||||
this.stacks = stacks2;
|
||||
return;
|
||||
}
|
||||
this.stacks = new ItemStack[var2];
|
||||
|
||||
for(int var3 = 0; var3 < var2; ++var3) {
|
||||
short var4 = var1.readShort();
|
||||
|
|
|
@ -127,7 +127,8 @@ public class PlayerControllerMP extends PlayerController {
|
|||
this.field_1080_g = this.field_9442_f;
|
||||
/*
|
||||
* Plays background music
|
||||
* Not needed as I already wrote my own system to play music
|
||||
* Not needed
|
||||
* I alr wrote my own system for it
|
||||
*/
|
||||
//this.mc.sndManager.func_4033_c();
|
||||
}
|
||||
|
|
|
@ -781,7 +781,7 @@ public class RenderGlobal implements IWorldAccess {
|
|||
var8 = this.worldObj.getBlockId(var2.blockX, var2.blockY, var2.blockZ);
|
||||
Block var9 = var8 > 0 ? Block.blocksList[var8] : null;
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
GL11.glPolygonOffset(3.0F, -3.0F);
|
||||
GL11.glPolygonOffset(-3.0F, -3.0F);
|
||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
var6.startDrawingQuads();
|
||||
double var10 = var1.lastTickPosX + (var1.posX - var1.lastTickPosX) * (double)var5;
|
||||
|
|
34
src/main/java/net/minecraft/src/ThreadConnectToServer.java
Normal file
34
src/main/java/net/minecraft/src/ThreadConnectToServer.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
class ThreadConnectToServer extends Thread {
|
||||
final Minecraft mc;
|
||||
final String uri;
|
||||
final GuiConnecting connectingGui;
|
||||
|
||||
ThreadConnectToServer(GuiConnecting var1, Minecraft var2, String var3) {
|
||||
this.connectingGui = var1;
|
||||
this.mc = var2;
|
||||
this.uri = var3;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
GuiConnecting.setNetClientHandler(this.connectingGui, new NetClientHandler(this.mc, this.uri));
|
||||
if(GuiConnecting.isCancelled(this.connectingGui)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GuiConnecting.getNetClientHandler(this.connectingGui).addToSendQueue(new Packet2Handshake(this.mc.field_6320_i.inventory));
|
||||
} catch (Exception var4) {
|
||||
if(GuiConnecting.isCancelled(this.connectingGui)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var4.printStackTrace();
|
||||
this.mc.displayGuiScreen(new GuiConnectFailed("Failed to connect to the server", var4.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -739,10 +739,8 @@ public class World implements IBlockAccess {
|
|||
}
|
||||
} else if(var1 == EnumSkyBlock.Block) {
|
||||
int var6 = this.getBlockId(var2, var3, var4);
|
||||
if(!(var6 < 0 || var6 > 256)) {
|
||||
if(Block.lightValue[var6] > var5) {
|
||||
var5 = Block.lightValue[var6];
|
||||
}
|
||||
if(Block.lightValue[var6] > var5) {
|
||||
var5 = Block.lightValue[var6];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.minecraft.src;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
@ -63,7 +64,6 @@ public class WorldClient extends World {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IChunkProvider func_4081_a(String var1) {
|
||||
this.C = new ChunkProviderClient(this);
|
||||
return this.C;
|
||||
|
|
23
src/teavm/java/Client.launch
Normal file
23
src/teavm/java/Client.launch
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/eclipseProject/src_lwjgl_java/net/lax1dude/eaglercraft/Client.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.lax1dude.eaglercraft.Client"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="eclipseProject"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="eclipseProject"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Djava.library.path=."/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc}/../"/>
|
||||
</launchConfiguration>
|
|
@ -1158,7 +1158,6 @@ public class EaglerAdapterImpl2 {
|
|||
|
||||
@JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=cvs.toDataURL(\"image/png\");a.download=name;a.click();")
|
||||
private static native void saveScreenshot(String name, HTMLCanvasElement cvs);
|
||||
|
||||
public static enum RateLimit {
|
||||
NONE, FAILED, BLOCKED, FAILED_POSSIBLY_LOCKED, LOCKED, NOW_LOCKED;
|
||||
}
|
||||
|
@ -1318,7 +1317,6 @@ public class EaglerAdapterImpl2 {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static final byte[] loadLocalStorage(String key) {
|
||||
String s = win.getLocalStorage().getItem("_eaglercraft_beta."+key);
|
||||
if(s != null) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user