1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-28 00:12:16 +00:00

Give FakeNetworkManager a nonnull channel.

Another mod was using mixins to access this private field without any
null checking. I got the idea to use an EmbeddedChannel from Carpet,
which was having the same issue with this mod.

Fixes #53.
This commit is contained in:
Toad-Dev 2022-02-07 23:16:41 -08:00
parent 31a3b975d3
commit 8ea1742135
3 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,18 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2022. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.fabric.mixin;
import io.netty.channel.Channel;
import net.minecraft.network.Connection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin( Connection.class )
public interface ConnectionAccess
{
@Accessor
void setChannel( Channel channel );
}

View File

@ -6,7 +6,9 @@
package dan200.computercraft.shared.util;
import dan200.computercraft.api.turtle.FakePlayer;
import dan200.computercraft.fabric.mixin.ConnectionAccess;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.Connection;
@ -283,6 +285,7 @@ public class FakeNetHandler extends ServerGamePacketListenerImpl
FakeNetworkManager()
{
super( PacketFlow.CLIENTBOUND );
((ConnectionAccess)this).setChannel( new EmbeddedChannel() );
}
@Override

View File

@ -3,6 +3,7 @@
"package": "dan200.computercraft.fabric.mixin",
"compatibilityLevel": "JAVA_16",
"mixins": [
"ConnectionAccess",
"LevelResourceAccess",
"MinecraftServerAccess",