From 67279df8648ab2dc0a2526463681a0d2bcc34f01 Mon Sep 17 00:00:00 2001 From: Cat Core <34719527+thecatcore@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:08:48 +0100 Subject: [PATCH] Fix crash on startup on MC1.7.10 (#162) * Closes Legacy-Fabric/fabric#161 * Fix typo in package name --- gradle.properties | 2 +- .../client/ClientPlayNetworkHandlerMixin.java | 39 +++++++++++++++++++ ...egacy-fabric-networking-api-v1.mixins.json | 7 ++-- .../client/ClientPlayNetworkHandlerMixin.java | 39 +++++++++++++++++++ ...egacy-fabric-networking-api-v1.mixins.json | 7 ++-- .../client/ClientPlayNetworkHandlerMixin.java | 39 +++++++++++++++++++ ...egacy-fabric-networking-api-v1.mixins.json | 7 ++-- .../ClientPlayNetworkHandlerExtensions.java | 4 ++ .../client/ClientPlayNetworkHandlerMixin.java | 4 +- 9 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 legacy-fabric-networking-api-v1/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java create mode 100644 legacy-fabric-networking-api-v1/1.7.10/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java create mode 100644 legacy-fabric-networking-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java diff --git a/gradle.properties b/gradle.properties index 03c7f762b..4fda2adbe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ legacy-fabric-item-groups-v1.version = 2.0.0 legacy-fabric-keybindings-api-v1.version = 1.0.1 legacy-fabric-lifecycle-events-v1.version = 1.0.1 legacy-fabric-logger-api-v1.version = 1.0.4 -legacy-fabric-networking-api-v1.version = 2.0.0 +legacy-fabric-networking-api-v1.version = 2.0.1 legacy-fabric-permissions-api-v1.version = 1.0.1 legacy-fabric-registry-sync-api-v1.version = 2.1.0 legacy-fabric-rendering-api-v1.version = 1.0.0 diff --git a/legacy-fabric-networking-api-v1/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java b/legacy-fabric-networking-api-v1/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java new file mode 100644 index 000000000..b3e2c9724 --- /dev/null +++ b/legacy-fabric-networking-api-v1/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 - 2022 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.mixin.networking.versioned.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.network.ClientPlayNetworkHandler; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import net.legacyfabric.fabric.impl.networking.client.ClientPlayNetworkHandlerExtensions; + +@Environment(EnvType.CLIENT) +@Mixin(value = ClientPlayNetworkHandler.class, priority = 999) +abstract class ClientPlayNetworkHandlerMixin implements ClientPlayNetworkHandlerExtensions { + @Inject(method = "", at = @At("RETURN")) + private void initAddon(CallbackInfo ci) { + this.lf$initAddon(); + } +} diff --git a/legacy-fabric-networking-api-v1/1.12.2/src/main/resources/legacy-fabric-networking-api-v1.mixins.json b/legacy-fabric-networking-api-v1/1.12.2/src/main/resources/legacy-fabric-networking-api-v1.mixins.json index 9aeebe0b3..a75644c36 100644 --- a/legacy-fabric-networking-api-v1/1.12.2/src/main/resources/legacy-fabric-networking-api-v1.mixins.json +++ b/legacy-fabric-networking-api-v1/1.12.2/src/main/resources/legacy-fabric-networking-api-v1.mixins.json @@ -3,14 +3,15 @@ "package": "net.legacyfabric.fabric.mixin.networking", "compatibilityLevel": "JAVA_8", "mixins": [ - "PlayerManagerMixin", "ClientConnectionMixin", + "CustomPayloadC2SPacketMixin", "MinecraftServerMixin", - "CustomPayloadC2SPacketMixin" + "PlayerManagerMixin" ], "client": [ + "client.CustomPayloadS2CPacketMixin", "client.MinecraftClientMixin", - "client.CustomPayloadS2CPacketMixin" + "versioned.client.ClientPlayNetworkHandlerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/legacy-fabric-networking-api-v1/1.7.10/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java b/legacy-fabric-networking-api-v1/1.7.10/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java new file mode 100644 index 000000000..b3e2c9724 --- /dev/null +++ b/legacy-fabric-networking-api-v1/1.7.10/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 - 2022 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.mixin.networking.versioned.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.network.ClientPlayNetworkHandler; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import net.legacyfabric.fabric.impl.networking.client.ClientPlayNetworkHandlerExtensions; + +@Environment(EnvType.CLIENT) +@Mixin(value = ClientPlayNetworkHandler.class, priority = 999) +abstract class ClientPlayNetworkHandlerMixin implements ClientPlayNetworkHandlerExtensions { + @Inject(method = "", at = @At("RETURN")) + private void initAddon(CallbackInfo ci) { + this.lf$initAddon(); + } +} diff --git a/legacy-fabric-networking-api-v1/1.7.10/src/main/resources/legacy-fabric-networking-api-v1.mixins.json b/legacy-fabric-networking-api-v1/1.7.10/src/main/resources/legacy-fabric-networking-api-v1.mixins.json index 76589c22c..a09e89bfc 100644 --- a/legacy-fabric-networking-api-v1/1.7.10/src/main/resources/legacy-fabric-networking-api-v1.mixins.json +++ b/legacy-fabric-networking-api-v1/1.7.10/src/main/resources/legacy-fabric-networking-api-v1.mixins.json @@ -3,15 +3,16 @@ "package": "net.legacyfabric.fabric.mixin.networking", "compatibilityLevel": "JAVA_8", "mixins": [ - "PlayerManagerMixin", "ClientConnectionMixin", + "CustomPayloadC2SPacketMixin", "MinecraftServerMixin", "PacketByteBufMixin", - "CustomPayloadC2SPacketMixin" + "PlayerManagerMixin" ], "client": [ + "client.CustomPayloadS2CPacketMixin", "client.MinecraftClientMixin", - "client.CustomPayloadS2CPacketMixin" + "versioned.client.ClientPlayNetworkHandlerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/legacy-fabric-networking-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java b/legacy-fabric-networking-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java new file mode 100644 index 000000000..b3e2c9724 --- /dev/null +++ b/legacy-fabric-networking-api-v1/1.8.9/src/main/java/net/legacyfabric/fabric/mixin/networking/versioned/client/ClientPlayNetworkHandlerMixin.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 - 2022 Legacy Fabric + * Copyright (c) 2016 - 2022 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.legacyfabric.fabric.mixin.networking.versioned.client; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import net.minecraft.client.network.ClientPlayNetworkHandler; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +import net.legacyfabric.fabric.impl.networking.client.ClientPlayNetworkHandlerExtensions; + +@Environment(EnvType.CLIENT) +@Mixin(value = ClientPlayNetworkHandler.class, priority = 999) +abstract class ClientPlayNetworkHandlerMixin implements ClientPlayNetworkHandlerExtensions { + @Inject(method = "", at = @At("RETURN")) + private void initAddon(CallbackInfo ci) { + this.lf$initAddon(); + } +} diff --git a/legacy-fabric-networking-api-v1/1.8.9/src/main/resources/legacy-fabric-networking-api-v1.mixins.json b/legacy-fabric-networking-api-v1/1.8.9/src/main/resources/legacy-fabric-networking-api-v1.mixins.json index 9aeebe0b3..a75644c36 100644 --- a/legacy-fabric-networking-api-v1/1.8.9/src/main/resources/legacy-fabric-networking-api-v1.mixins.json +++ b/legacy-fabric-networking-api-v1/1.8.9/src/main/resources/legacy-fabric-networking-api-v1.mixins.json @@ -3,14 +3,15 @@ "package": "net.legacyfabric.fabric.mixin.networking", "compatibilityLevel": "JAVA_8", "mixins": [ - "PlayerManagerMixin", "ClientConnectionMixin", + "CustomPayloadC2SPacketMixin", "MinecraftServerMixin", - "CustomPayloadC2SPacketMixin" + "PlayerManagerMixin" ], "client": [ + "client.CustomPayloadS2CPacketMixin", "client.MinecraftClientMixin", - "client.CustomPayloadS2CPacketMixin" + "versioned.client.ClientPlayNetworkHandlerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/impl/networking/client/ClientPlayNetworkHandlerExtensions.java b/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/impl/networking/client/ClientPlayNetworkHandlerExtensions.java index 080de3076..0d53aa9e3 100644 --- a/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/impl/networking/client/ClientPlayNetworkHandlerExtensions.java +++ b/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/impl/networking/client/ClientPlayNetworkHandlerExtensions.java @@ -17,10 +17,14 @@ package net.legacyfabric.fabric.impl.networking.client; +import org.jetbrains.annotations.ApiStatus; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) public interface ClientPlayNetworkHandlerExtensions { ClientPlayNetworkAddon getAddon(); + @ApiStatus.Internal + void lf$initAddon(); } diff --git a/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/networking/client/ClientPlayNetworkHandlerMixin.java b/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/networking/client/ClientPlayNetworkHandlerMixin.java index ec1703348..4a472eb7e 100644 --- a/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/networking/client/ClientPlayNetworkHandlerMixin.java +++ b/legacy-fabric-networking-api-v1/common/src/main/java/net/legacyfabric/fabric/mixin/networking/client/ClientPlayNetworkHandlerMixin.java @@ -47,8 +47,8 @@ abstract class ClientPlayNetworkHandlerMixin implements ClientPlayNetworkHandler @Unique private ClientPlayNetworkAddon addon; - @Inject(method = "", at = @At("RETURN")) - private void initAddon(CallbackInfo ci) { + @Override + public void lf$initAddon() { this.addon = new ClientPlayNetworkAddon((ClientPlayNetworkHandler) (Object) this, this.client); // A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field ClientNetworkingImpl.setClientPlayAddon(this.addon);