Skip to content

Commit

Permalink
Fix crash on startup on MC1.7.10 (#162)
Browse files Browse the repository at this point in the history
* Closes #161

* Fix typo in package name
  • Loading branch information
thecatcore authored Feb 22, 2024
1 parent c140ada commit 67279df
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "<init>", at = @At("RETURN"))
private void initAddon(CallbackInfo ci) {
this.lf$initAddon();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "<init>", at = @At("RETURN"))
private void initAddon(CallbackInfo ci) {
this.lf$initAddon();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = "<init>", at = @At("RETURN"))
private void initAddon(CallbackInfo ci) {
this.lf$initAddon();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ abstract class ClientPlayNetworkHandlerMixin implements ClientPlayNetworkHandler
@Unique
private ClientPlayNetworkAddon addon;

@Inject(method = "<init>", 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);
Expand Down

0 comments on commit 67279df

Please sign in to comment.