Some fixes, stuck on downloading terrain

This commit is contained in:
catfoolyou 2025-02-25 11:29:11 -05:00
parent f2c62cf5c7
commit cf21caabb0
21 changed files with 106 additions and 157 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="corretto-18" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-18" project-jdk-type="JavaSDK" />
</project> </project>

View File

@ -71,6 +71,8 @@ public final class UserConnection implements ProxiedPlayer
private int clientEntityId; private int clientEntityId;
private final Map<String, Object> attachment = new WeakHashMap();
public void setServer(ServerConnection server) { public void setServer(ServerConnection server) {
this.server = server; this.server = server;
} }
@ -239,11 +241,11 @@ public final class UserConnection implements ProxiedPlayer
this.tabList = tabList; this.tabList = tabList;
} }
public void sendPacket(PacketWrapper packet) public void sendPacket(final byte[] b) {
{ this.ch.write(b);
ch.write( packet );
} }
@Deprecated @Deprecated
public boolean isActive() public boolean isActive()
{ {
@ -429,8 +431,7 @@ public final class UserConnection implements ProxiedPlayer
@Override @Override
public Map<String, Object> getAttachment() { // fix this (maybe) public Map<String, Object> getAttachment() { // fix this (maybe)
System.out.println("This might be a problem"); return attachment;
return Map.of();
} }
@Override @Override

View File

@ -9,6 +9,7 @@ import java.io.DataInput;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.Objects; import java.util.Objects;
import io.netty.buffer.Unpooled;
import net.md_5.bungee.*; import net.md_5.bungee.*;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
@ -71,12 +72,10 @@ public class DownstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(PacketWrapper packet) throws Exception public void handle(final byte[] buf) throws Exception {
{ if (!this.server.isObsolete()) {
if ( !server.isObsolete() ) EntityMap.rewrite(Unpooled.wrappedBuffer(buf), this.con.getServerEntityId(), this.con.getClientEntityId());
{ this.con.sendPacket(buf);
EntityMap.rewrite( packet.buf, con.getServerEntityId(), con.getClientEntityId() );
con.sendPacket( packet );
} }
} }

View File

@ -65,6 +65,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection {
@Override @Override
public void connected(final ChannelWrapper channel) throws Exception { public void connected(final ChannelWrapper channel) throws Exception {
System.out.println("[InitialHandler] - connected (I think)");
this.ch = channel; this.ch = channel;
} }

View File

@ -1,5 +1,6 @@
package net.md_5.bungee.connection; package net.md_5.bungee.connection;
import io.netty.buffer.Unpooled;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.EntityMap; import net.md_5.bungee.EntityMap;
import net.md_5.bungee.UserConnection; import net.md_5.bungee.UserConnection;
@ -57,12 +58,10 @@ public class UpstreamBridge extends PacketHandler
} }
@Override @Override
public void handle(PacketWrapper packet) throws Exception public void handle(final byte[] buf) throws Exception {
{ EntityMap.rewrite(Unpooled.wrappedBuffer(buf), this.con.getClientEntityId(), this.con.getServerEntityId());
EntityMap.rewrite( packet.buf, con.getClientEntityId(), con.getServerEntityId() ); if (this.con.getServer() != null && this.con.getServer().getCh() != null) {
if ( con.getServer() != null ) this.con.getServer().getCh().write(buf); // Change to buf if its a problem
{
con.getServer().getCh().write( packet );
} }
} }

View File

@ -180,7 +180,6 @@ public class WebSocketListener extends WebSocketServer {
System.out.println("[WebsocketListener] - onMessage called"); System.out.println("[WebsocketListener] - onMessage called");
Object o = arg0.getAttachment(); Object o = arg0.getAttachment();
if(o == null || (o instanceof PendingSocket)) { if(o == null || (o instanceof PendingSocket)) {
System.out.println("o is null");
InetAddress realAddr; InetAddress realAddr;
if(o == null) { if(o == null) {
realAddr = arg0.getRemoteSocketAddress().getAddress(); realAddr = arg0.getRemoteSocketAddress().getAddress();
@ -210,7 +209,6 @@ public class WebSocketListener extends WebSocketServer {
o = proxyObj; o = proxyObj;
} }
if(o != null) { if(o != null) {
System.out.println("o is not null");
if(o instanceof WebSocketProxy) { if(o instanceof WebSocketProxy) {
System.out.println("Instance of WebSocketProxy, sending packet"); System.out.println("Instance of WebSocketProxy, sending packet");
((WebSocketProxy)o).sendPacket(arg1); ((WebSocketProxy)o).sendPacket(arg1);

View File

@ -1,123 +1,88 @@
//
// Decompiled by Procyon v0.5.36
//
package net.md_5.bungee.netty; package net.md_5.bungee.netty;
import com.google.common.base.Preconditions;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.timeout.ReadTimeoutException;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import com.google.common.base.Preconditions;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.MessageList;
import io.netty.handler.timeout.ReadTimeoutException;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.connection.CancelSendSignal; import net.md_5.bungee.connection.CancelSendSignal;
import net.md_5.bungee.connection.InitialHandler; import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.connection.PingHandler; import net.md_5.bungee.connection.PingHandler;
import net.md_5.bungee.protocol.BadPacketException;
/**
* This class is a primitive wrapper for {@link PacketHandler} instances tied to
* channels to maintain simple states, and only call the required, adapted
* methods when the channel is connected.
*/
public class HandlerBoss extends ChannelInboundHandlerAdapter
{
public class HandlerBoss extends ChannelInboundHandlerAdapter {
private ChannelWrapper channel; private ChannelWrapper channel;
private PacketHandler handler; private PacketHandler handler;
public void setHandler(PacketHandler handler) public void setHandler(final PacketHandler handler) {
{ Preconditions.checkArgument(handler != null, (Object) "handler");
Preconditions.checkArgument( handler != null, "handler" );
this.handler = handler; this.handler = handler;
} }
@Override public void channelActive(final ChannelHandlerContext ctx) throws Exception {
public void channelActive(ChannelHandlerContext ctx) throws Exception if (this.handler != null) {
{ this.channel = new ChannelWrapper(ctx);
if ( handler != null ) this.handler.connected(this.channel);
{ if (!(this.handler instanceof InitialHandler) && !(this.handler instanceof PingHandler)) {
channel = new ChannelWrapper( ctx ); ProxyServer.getInstance().getLogger().log(Level.INFO, "{0} has connected", this.handler);
handler.connected( channel );
if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler );
} }
} }
} }
@Override public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
public void channelInactive(ChannelHandlerContext ctx) throws Exception if (this.handler != null) {
{ this.handler.disconnected(this.channel);
if ( handler != null ) if (!(this.handler instanceof InitialHandler) && !(this.handler instanceof PingHandler)) {
{ ProxyServer.getInstance().getLogger().log(Level.INFO, "{0} has disconnected", this.handler);
handler.disconnected( channel );
if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
} }
} }
} }
//@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageList<Object> msgs) throws Exception {
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception for (final Object msg : msgs) {
{ if (this.handler != null && ctx.channel().isActive()) {
if ( handler != null ) if (msg instanceof PacketWrapper) {
{
PacketWrapper packet = (PacketWrapper) msg;
boolean sendPacket = true; boolean sendPacket = true;
try try {
{ ((PacketWrapper) msg).packet.handle(this.handler);
if ( packet.packet != null ) } catch (CancelSendSignal ex) {
{
try
{
packet.packet.handle( handler );
} catch ( CancelSendSignal ex )
{
sendPacket = false; sendPacket = false;
} }
if (!sendPacket) {
continue;
} }
if ( sendPacket ) this.handler.handle(((PacketWrapper) msg).buf);
{ } else {
handler.handle( packet ); this.handler.handle((byte[]) msg);
} }
} finally
{
packet.trySingleRelease();
} }
} }
} }
@Override public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception if (ctx.channel().isActive()) {
{ if (cause instanceof ReadTimeoutException) {
if ( ctx.channel().isActive() ) ProxyServer.getInstance().getLogger().log(Level.WARNING, this.handler + " - read timed out");
{ } else if (cause instanceof IOException) {
if ( cause instanceof ReadTimeoutException ) ProxyServer.getInstance().getLogger().log(Level.WARNING, this.handler + " - IOException: " + cause.getMessage());
{ } else {
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - read timed out" ); ProxyServer.getInstance().getLogger().log(Level.SEVERE, this.handler + " - encountered exception", cause);
} else if ( cause instanceof BadPacketException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - bad packet ID, are mods in use!?" );
} else if ( cause instanceof IOException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - IOException: " + cause.getMessage() );
} else
{
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause );
} }
if (this.handler != null) {
if ( handler != null ) try {
{ this.handler.exception(cause);
try } catch (Exception ex) {
{ ProxyServer.getInstance().getLogger().log(Level.SEVERE, this.handler + " - exception processing exception", ex);
handler.exception( cause );
} catch ( Exception ex )
{
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - exception processing exception", ex );
} }
} }
ctx.close(); ctx.close();
} }
} }

View File

@ -28,7 +28,7 @@ public class PacketDecoder extends ReplayingDecoder<Void> {
in.readerIndex(endIndex); in.readerIndex(endIndex);
this.checkpoint(); this.checkpoint();
if (packet != null) { if (packet != null) {
out.add((Object) new PacketWrapper(packet, Unpooled.wrappedBuffer(buf))); out.add((Object) new PacketWrapper(packet, buf));
} else { } else {
out.add((Object) buf); out.add((Object) buf);
} }

View File

@ -10,7 +10,7 @@ public abstract class PacketHandler extends net.md_5.bungee.protocol.packet.Abst
{ {
} }
public void handle(PacketWrapper packet) throws Exception public void handle(byte[] buf) throws Exception
{ {
} }

View File

@ -1,31 +1,13 @@
package net.md_5.bungee.netty; package net.md_5.bungee.netty;
import io.netty.buffer.ByteBuf;
import net.md_5.bungee.protocol.packet.DefinedPacket; import net.md_5.bungee.protocol.packet.DefinedPacket;
public class PacketWrapper public class PacketWrapper {
{ DefinedPacket packet;
byte[] buf;
public final DefinedPacket packet; public PacketWrapper(final DefinedPacket packet, final byte[] buf) {
public final ByteBuf buf;
public PacketWrapper(DefinedPacket packet, ByteBuf buf) {
this.packet = packet; this.packet = packet;
this.buf = buf; this.buf = buf;
} }
public void setReleased(boolean released) {
this.released = released;
}
private boolean released;
public void trySingleRelease()
{
if ( !released )
{
buf.release();
released = true;
}
}
} }

Binary file not shown.

View File

@ -1093,6 +1093,7 @@ public class EaglerAdapterImpl2 {
@Override @Override
public void onMessage(ByteBuffer arg0) { public void onMessage(ByteBuffer arg0) {
System.out.println("OnMessage called (important)");
wasAbleToConnect = true; wasAbleToConnect = true;
synchronized(socketSync) { synchronized(socketSync) {
readPackets.add(arg0.array()); readPackets.add(arg0.array());

View File

@ -48,11 +48,12 @@ public class ActiveRenderInfo
/** /**
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode * Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
*/ */
public static void updateRenderInfo(EntityPlayer par0EntityPlayer, boolean par1) public static void updateRenderInfo(EntityPlayer par0EntityPlayer, boolean par1) {
{ modelview.clear(); projection.clear();
EaglerAdapter.glGetFloat(EaglerAdapter.GL_MODELVIEW_MATRIX, modelview); EaglerAdapter.glGetFloat(EaglerAdapter.GL_MODELVIEW_MATRIX, modelview);
EaglerAdapter.glGetFloat(EaglerAdapter.GL_PROJECTION_MATRIX, projection); EaglerAdapter.glGetFloat(EaglerAdapter.GL_PROJECTION_MATRIX, projection);
EaglerAdapter.glGetInteger(EaglerAdapter.GL_VIEWPORT, viewport); EaglerAdapter.glGetInteger(EaglerAdapter.GL_VIEWPORT, viewport);
modelview.position(0); projection.position(0); objectCoords.position(0);
float var2 = (float) ((viewport[0] + viewport[2]) / 2); float var2 = (float) ((viewport[0] + viewport[2]) / 2);
float var3 = (float) ((viewport[1] + viewport[3]) / 2); float var3 = (float) ((viewport[1] + viewport[3]) / 2);
EaglerAdapter.gluUnProject(var2, var3, 0.0F, modelview, projection, viewport, objectCoords); EaglerAdapter.gluUnProject(var2, var3, 0.0F, modelview, projection, viewport, objectCoords);
@ -62,11 +63,11 @@ public class ActiveRenderInfo
int var4 = par1 ? 1 : 0; int var4 = par1 ? 1 : 0;
float var5 = par0EntityPlayer.rotationPitch; float var5 = par0EntityPlayer.rotationPitch;
float var6 = par0EntityPlayer.rotationYaw; float var6 = par0EntityPlayer.rotationYaw;
rotationX = MathHelper.cos(var6 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2); rotationX = MathHelper.cos(var6 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
rotationZ = MathHelper.sin(var6 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2); rotationZ = MathHelper.sin(var6 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
rotationYZ = -rotationZ * MathHelper.sin(var5 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2); rotationYZ = -rotationZ * MathHelper.sin(var5 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
rotationXY = rotationX * MathHelper.sin(var5 * (float)Math.PI / 180.0F) * (float)(1 - var4 * 2); rotationXY = rotationX * MathHelper.sin(var5 * (float) Math.PI / 180.0F) * (float) (1 - var4 * 2);
rotationXZ = MathHelper.cos(var5 * (float)Math.PI / 180.0F); rotationXZ = MathHelper.cos(var5 * (float) Math.PI / 180.0F);
} }
/** /**

View File

@ -85,10 +85,10 @@ public class EntityPlayerSP extends EntityPlayer
} }
else else
{ {
if (!this.mc.statFileWriter.hasAchievementUnlocked(AchievementList.openInventory)) /*if (!this.mc.statFileWriter.hasAchievementUnlocked(AchievementList.openInventory))
{ {
this.mc.guiAchievement.queueAchievementInformation(AchievementList.openInventory); this.mc.guiAchievement.queueAchievementInformation(AchievementList.openInventory);
} }*/
this.prevTimeInPortal = this.timeInPortal; this.prevTimeInPortal = this.timeInPortal;
@ -490,7 +490,7 @@ public class EntityPlayerSP extends EntityPlayer
*/ */
public void addStat(StatBase par1StatBase, int par2) public void addStat(StatBase par1StatBase, int par2)
{ {
if (par1StatBase != null) /*if (par1StatBase != null)
{ {
if (par1StatBase.isAchievement()) if (par1StatBase.isAchievement())
{ {
@ -510,7 +510,7 @@ public class EntityPlayerSP extends EntityPlayer
{ {
this.mc.statFileWriter.readStat(par1StatBase, par2); this.mc.statFileWriter.readStat(par1StatBase, par2);
} }
} }*/
} }
private boolean isBlockTranslucent(int par1, int par2, int par3) private boolean isBlockTranslucent(int par1, int par2, int par3)

View File

@ -880,12 +880,12 @@ public class GuiContainerCreative extends InventoryEffectRenderer
{ {
if (par1GuiButton.id == 0) if (par1GuiButton.id == 0)
{ {
this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter)); //this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter));
} }
if (par1GuiButton.id == 1) if (par1GuiButton.id == 1)
{ {
this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter)); //this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter));
} }
} }

View File

@ -284,7 +284,7 @@ public class GuiCreateWorld extends GuiScreen
} }
this.mc.launchIntegratedServer(this.folderName, this.textboxWorldName.getText().trim(), var6); this.mc.launchIntegratedServer(this.folderName, this.textboxWorldName.getText().trim(), var6);
this.mc.statFileWriter.readStat(StatList.createWorldStat, 1); //this.mc.statFileWriter.readStat(StatList.createWorldStat, 1);
} }
else if (par1GuiButton.id == 3) else if (par1GuiButton.id == 3)
{ {

View File

@ -46,7 +46,7 @@ public class GuiIngameMenu extends GuiScreen
case 1: case 1:
par1GuiButton.enabled = false; par1GuiButton.enabled = false;
this.mc.statFileWriter.readStat(StatList.leaveGameStat, 1); //this.mc.statFileWriter.readStat(StatList.leaveGameStat, 1);
this.mc.theWorld.sendQuittingDisconnectingPacket(); this.mc.theWorld.sendQuittingDisconnectingPacket();
this.mc.loadWorld((WorldClient)null); this.mc.loadWorld((WorldClient)null);
this.mc.displayGuiScreen(new GuiMainMenu()); this.mc.displayGuiScreen(new GuiMainMenu());
@ -63,11 +63,11 @@ public class GuiIngameMenu extends GuiScreen
break; break;
case 5: case 5:
this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter)); //this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter));
break; break;
case 6: case 6:
this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter)); //this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter));
break; break;
case 7: case 7:

View File

@ -124,12 +124,12 @@ public class GuiInventory extends InventoryEffectRenderer
{ {
if (par1GuiButton.id == 0) if (par1GuiButton.id == 0)
{ {
this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter)); //this.mc.displayGuiScreen(new GuiAchievements(this.mc.statFileWriter));
} }
if (par1GuiButton.id == 1) if (par1GuiButton.id == 1)
{ {
this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter)); //this.mc.displayGuiScreen(new GuiStats(this, this.mc.statFileWriter));
} }
} }
} }

View File

@ -211,7 +211,7 @@ public class GuiSelectWorld extends GuiScreen
if (this.mc.getSaveLoader().canLoadWorld(var2)) if (this.mc.getSaveLoader().canLoadWorld(var2))
{ {
this.mc.launchIntegratedServer(var2, var3, (WorldSettings)null); this.mc.launchIntegratedServer(var2, var3, (WorldSettings)null);
this.mc.statFileWriter.readStat(StatList.loadWorldStat, 1); //this.mc.statFileWriter.readStat(StatList.loadWorldStat, 1);
} }
} }
} }

View File

@ -110,7 +110,7 @@ public class Minecraft
private boolean refreshTexturePacksScheduled; private boolean refreshTexturePacksScheduled;
/** Stat file writer */ /** Stat file writer */
public StatFileWriter statFileWriter; //public StatFileWriter statFileWriter;
private String serverName; private String serverName;
private int serverPort; private int serverPort;
@ -1486,6 +1486,7 @@ public class Minecraft
this.effectRenderer.updateEffects(); this.effectRenderer.updateEffects();
} }
} else if (this.myNetworkManager != null) { } else if (this.myNetworkManager != null) {
this.myNetworkManager.processReadPackets(); this.myNetworkManager.processReadPackets();
} else { } else {
this.entityRenderer.startup = 0; this.entityRenderer.startup = 0;
@ -1609,7 +1610,7 @@ public class Minecraft
*/ */
public void loadWorld(WorldClient par1WorldClient, String par2Str) // FIX THIS SHIT public void loadWorld(WorldClient par1WorldClient, String par2Str) // FIX THIS SHIT
{ {
/*this.statFileWriter.syncStats(); //this.statFileWriter.syncStats();
if (par1WorldClient == null) if (par1WorldClient == null)
{ {
@ -1627,7 +1628,7 @@ public class Minecraft
if (this.theIntegratedServer != null) if (this.theIntegratedServer != null)
{ {
this.theIntegratedServer.initiateShutdown(); //this.theIntegratedServer.initiateShutdown();
} }
this.theIntegratedServer = null; this.theIntegratedServer = null;
@ -1678,12 +1679,12 @@ public class Minecraft
} }
else else
{ {
this.saveLoader.flushCache(); //this.saveLoader.flushCache();
this.thePlayer = null; this.thePlayer = null;
} }
System.gc(); System.gc();
this.systemTime = 0L;*/ this.systemTime = 0L;
} }
public void setNetManager(INetworkManager nm) { public void setNetManager(INetworkManager nm) {

View File

@ -91,6 +91,7 @@ public class NetClientHandler extends NetHandler {
*/ */
public void processReadPackets() { public void processReadPackets() {
if (this.netManager != null) { if (this.netManager != null) {
System.out.println("[NetClientHandler] - processReadPackets called");
this.netManager.processReadPackets(); this.netManager.processReadPackets();
} }