Skip to content

Commit 199969b

Browse files
committed
[networking] fix crash if disconnected before login
1 parent bfb666b commit 199969b

13 files changed

Lines changed: 150 additions & 56 deletions

File tree

‎libraries/networking-impl/networking-impl-mc1.13-pre3-mc1.13-pre3/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientPlayNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
4646
private Set<NamespacedIdentifier> serverChannels;
4747

4848
@Inject(
49-
method = "handleLogin",
49+
method = "<init>*",
5050
at = @At(
5151
value = "TAIL"
5252
)
5353
)
54-
private void osl$networking$handleLogin(CallbackInfo ci) {
54+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5555
if (minecraft.isIntegratedServerRunning()) {
5656
IntegratedServer server = minecraft.getServer();
5757
String worldName = server.getWorldName();
@@ -65,7 +65,15 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
6565

6666
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6767
}
68+
}
6869

70+
@Inject(
71+
method = "handleLogin",
72+
at = @At(
73+
value = "TAIL"
74+
)
75+
)
76+
private void osl$networking$handleLogin(CallbackInfo ci) {
6977
// send channel registration data as soon as login occurs
7078
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7179

‎libraries/networking-impl/networking-impl-mc1.13-pre4-mc1.13.2/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientPlayNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
4646
private Set<NamespacedIdentifier> serverChannels;
4747

4848
@Inject(
49-
method = "handleLogin",
49+
method = "<init>*",
5050
at = @At(
5151
value = "TAIL"
5252
)
5353
)
54-
private void osl$networking$handleLogin(CallbackInfo ci) {
54+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5555
if (minecraft.isIntegratedServerRunning()) {
5656
IntegratedServer server = minecraft.getServer();
5757
String worldName = server.getWorldName();
@@ -65,7 +65,15 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
6565

6666
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6767
}
68+
}
6869

70+
@Inject(
71+
method = "handleLogin",
72+
at = @At(
73+
value = "TAIL"
74+
)
75+
)
76+
private void osl$networking$handleLogin(CallbackInfo ci) {
6977
// send channel registration data as soon as login occurs
7078
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7179

‎libraries/networking-impl/networking-impl-mc11w49a-mc12w16a/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientNetworkHandlerMixin.java‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,27 @@ public class ClientNetworkHandlerMixin implements ClientNetworkHandlerAccess, Pa
4848
private Set<NamespacedIdentifier> serverChannels;
4949

5050
@Inject(
51-
method = "handleLogin",
51+
method = "<init>*",
5252
at = @At(
5353
value = "TAIL"
5454
)
5555
)
56-
private void osl$networking$handleLogin(CallbackInfo ci) {
57-
{
58-
SocketAddress address = connection.socket.getRemoteSocketAddress();
56+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
57+
SocketAddress address = connection.socket.getRemoteSocketAddress();
5958

60-
String serverAddress = AddressParser.getAddress(address);
61-
int serverPort = AddressParser.getPort(address);
59+
String serverAddress = AddressParser.getAddress(address);
60+
int serverPort = AddressParser.getPort(address);
6261

63-
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
64-
}
62+
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
63+
}
6564

65+
@Inject(
66+
method = "handleLogin",
67+
at = @At(
68+
value = "TAIL"
69+
)
70+
)
71+
private void osl$networking$handleLogin(CallbackInfo ci) {
6672
// send channel registration data as soon as login occurs
6773
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
6874

‎libraries/networking-impl/networking-impl-mc12w17a-mc12w17a/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientNetworkHandlerMixin.java‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,27 @@ public class ClientNetworkHandlerMixin implements ClientNetworkHandlerAccess, Pa
4848
private Set<NamespacedIdentifier> serverChannels;
4949

5050
@Inject(
51-
method = "handleLogin",
51+
method = "<init>*",
5252
at = @At(
5353
value = "TAIL"
5454
)
5555
)
56-
private void osl$networking$handleLogin(CallbackInfo ci) {
57-
{
58-
SocketAddress address = connection.socket.getRemoteSocketAddress();
56+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
57+
SocketAddress address = connection.socket.getRemoteSocketAddress();
5958

60-
String serverAddress = AddressParser.getAddress(address);
61-
int serverPort = AddressParser.getPort(address);
59+
String serverAddress = AddressParser.getAddress(address);
60+
int serverPort = AddressParser.getPort(address);
6261

63-
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
64-
}
62+
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
63+
}
6564

65+
@Inject(
66+
method = "handleLogin",
67+
at = @At(
68+
value = "TAIL"
69+
)
70+
)
71+
private void osl$networking$handleLogin(CallbackInfo ci) {
6672
// send channel registration data as soon as login occurs
6773
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
6874

‎libraries/networking-impl/networking-impl-mc12w18a-mc12w19a/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public class ClientNetworkHandlerMixin implements ClientNetworkHandlerAccess {
4848
private Set<NamespacedIdentifier> serverChannels;
4949

5050
@Inject(
51-
method = "handleLogin",
51+
method = "<init>*",
5252
at = @At(
5353
value = "TAIL"
5454
)
5555
)
56-
private void osl$networking$handleLogin(CallbackInfo ci) {
56+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5757
if (minecraft.getLocalServer().isRunning()) {
5858
LocalServerAccess server = (LocalServerAccess) minecraft.getLocalServer();
5959
String worldName = server.osl$networking$worldSaveName();
@@ -67,7 +67,15 @@ public class ClientNetworkHandlerMixin implements ClientNetworkHandlerAccess {
6767

6868
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6969
}
70+
}
7071

72+
@Inject(
73+
method = "handleLogin",
74+
at = @At(
75+
value = "TAIL"
76+
)
77+
)
78+
private void osl$networking$handleLogin(CallbackInfo ci) {
7179
// send channel registration data as soon as login occurs
7280
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7381

‎libraries/networking-impl/networking-impl-mc12w21a-mc13w39b/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public class ClientNetworkHandlerMixin implements ClientNetworkHandlerAccess {
4848
private Set<NamespacedIdentifier> serverChannels;
4949

5050
@Inject(
51-
method = "handleLogin",
51+
method = "<init>*",
5252
at = @At(
5353
value = "TAIL"
5454
)
5555
)
56-
private void osl$networking$handleLogin(CallbackInfo ci) {
56+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5757
if (minecraft.isIntegratedServerRunning()) {
5858
IntegratedServer server = minecraft.getServer();
5959
String worldName = server.getWorldName();
@@ -67,7 +67,15 @@ public class ClientNetworkHandlerMixin implements ClientNetworkHandlerAccess {
6767

6868
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6969
}
70+
}
7071

72+
@Inject(
73+
method = "handleLogin",
74+
at = @At(
75+
value = "TAIL"
76+
)
77+
)
78+
private void osl$networking$handleLogin(CallbackInfo ci) {
7179
// send channel registration data as soon as login occurs
7280
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7381

‎libraries/networking-impl/networking-impl-mc13w41a-mc14w20b/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientPlayNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
4646
private Set<NamespacedIdentifier> serverChannels;
4747

4848
@Inject(
49-
method = "handleLogin",
49+
method = "<init>*",
5050
at = @At(
5151
value = "TAIL"
5252
)
5353
)
54-
private void osl$networking$handleLogin(CallbackInfo ci) {
54+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5555
if (minecraft.isIntegratedServerRunning()) {
5656
IntegratedServer server = minecraft.getServer();
5757
String worldName = server.getWorldName();
@@ -65,7 +65,15 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
6565

6666
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6767
}
68+
}
6869

70+
@Inject(
71+
method = "handleLogin",
72+
at = @At(
73+
value = "TAIL"
74+
)
75+
)
76+
private void osl$networking$handleLogin(CallbackInfo ci) {
6977
// send channel registration data as soon as login occurs
7078
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7179

‎libraries/networking-impl/networking-impl-mc14w21a-mc14w30c/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientPlayNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
4646
private Set<NamespacedIdentifier> serverChannels;
4747

4848
@Inject(
49-
method = "handleLogin",
49+
method = "<init>*",
5050
at = @At(
5151
value = "TAIL"
5252
)
5353
)
54-
private void osl$networking$handleLogin(CallbackInfo ci) {
54+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5555
if (minecraft.isIntegratedServerRunning()) {
5656
IntegratedServer server = minecraft.getServer();
5757
String worldName = server.getWorldName();
@@ -65,7 +65,15 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
6565

6666
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6767
}
68+
}
6869

70+
@Inject(
71+
method = "handleLogin",
72+
at = @At(
73+
value = "TAIL"
74+
)
75+
)
76+
private void osl$networking$handleLogin(CallbackInfo ci) {
6977
// send channel registration data as soon as login occurs
7078
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7179

‎libraries/networking-impl/networking-impl-mc14w31a-mc1.13-pre2/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientPlayNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
4646
private Set<NamespacedIdentifier> serverChannels;
4747

4848
@Inject(
49-
method = "handleLogin",
49+
method = "<init>*",
5050
at = @At(
5151
value = "TAIL"
5252
)
5353
)
54-
private void osl$networking$handleLogin(CallbackInfo ci) {
54+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5555
if (minecraft.isIntegratedServerRunning()) {
5656
IntegratedServer server = minecraft.getServer();
5757
String worldName = server.getWorldName();
@@ -65,7 +65,15 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
6565

6666
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6767
}
68+
}
6869

70+
@Inject(
71+
method = "handleLogin",
72+
at = @At(
73+
value = "TAIL"
74+
)
75+
)
76+
private void osl$networking$handleLogin(CallbackInfo ci) {
6977
// send channel registration data as soon as login occurs
7078
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7179

‎libraries/networking-impl/networking-impl-mc18w43a-mc1.14.4/src/main/java/net/ornithemc/osl/networking/impl/mixin/client/ClientPlayNetworkHandlerMixin.java‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
4646
private Set<NamespacedIdentifier> serverChannels;
4747

4848
@Inject(
49-
method = "handleLogin",
49+
method = "<init>*",
5050
at = @At(
5151
value = "TAIL"
5252
)
5353
)
54-
private void osl$networking$handleLogin(CallbackInfo ci) {
54+
private void osl$networking$initConnectionContext(CallbackInfo ci) {
5555
if (minecraft.isIntegratedServerRunning()) {
5656
IntegratedServer server = minecraft.getServer();
5757
String worldName = server.getWorldName();
@@ -65,7 +65,15 @@ public class ClientPlayNetworkHandlerMixin implements ClientNetworkHandlerAccess
6565

6666
connectionContext = new ClientConnectionContext(minecraft, serverAddress, serverPort);
6767
}
68+
}
6869

70+
@Inject(
71+
method = "handleLogin",
72+
at = @At(
73+
value = "TAIL"
74+
)
75+
)
76+
private void osl$networking$handleLogin(CallbackInfo ci) {
6977
// send channel registration data as soon as login occurs
7078
ClientPlayNetworkingImpl.sendNoCheck(HandshakePayload.CHANNEL, HandshakePayload.client());
7179

0 commit comments

Comments
 (0)