Skip to content

Commit

Permalink
Fix invalid ClientPacketListener mixin
Browse files Browse the repository at this point in the history
client is crashing when joining a singleplayer world because of invalid mixin reference
  • Loading branch information
ImMorpheus committed Nov 18, 2023
1 parent e902b93 commit 352144a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This file is part of Sponge, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.common.mixin.api.minecraft.client.multiplayer;

import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ClientCommonPacketListenerImpl.class)
public abstract class ClientCommonPacketListenerImpl_API {
@Shadow @Final protected Minecraft minecraft;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@
*/
package org.spongepowered.common.mixin.api.minecraft.client.multiplayer;

import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import org.spongepowered.api.entity.living.player.client.LocalPlayer;
import org.spongepowered.api.network.LocalPlayerConnection;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ClientPacketListener.class)
public abstract class ClientPacketListenerMixin_API implements LocalPlayerConnection {

// @formatter:off
@Shadow @Final private Minecraft minecraft;
// @formatter:on
public abstract class ClientPacketListenerMixin_API extends ClientCommonPacketListenerImpl_API implements LocalPlayerConnection {

@Override
public LocalPlayer player() {
Expand Down
1 change: 1 addition & 0 deletions src/mixins/resources/mixins.sponge.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
"minecraft.client.MinecraftMixin_API",
"minecraft.client.multiplayer.ClientLevel_ClientLevelDataMixin_API",
"minecraft.client.multiplayer.ClientLevelMixin_API",
"minecraft.client.multiplayer.ClientCommonPacketListenerImpl_API",
"minecraft.client.multiplayer.ClientPacketListenerMixin_API",
"minecraft.client.network.ClientNetHandlerMixin_API",
"minecraft.client.player.AbstractClientPlayerMixin_API",
Expand Down

0 comments on commit 352144a

Please sign in to comment.