diff --git a/src/main/java/dan200/computercraft/fabric/mixin/ConnectionAccess.java b/src/main/java/dan200/computercraft/fabric/mixin/ConnectionAccess.java new file mode 100644 index 000000000..6521317cb --- /dev/null +++ b/src/main/java/dan200/computercraft/fabric/mixin/ConnectionAccess.java @@ -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 ); +} diff --git a/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java b/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java index 1920f7f0e..9a8480852 100644 --- a/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java +++ b/src/main/java/dan200/computercraft/shared/util/FakeNetHandler.java @@ -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 diff --git a/src/main/resources/computercraft.mixins.json b/src/main/resources/computercraft.mixins.json index b00acb4ef..f92f23b39 100644 --- a/src/main/resources/computercraft.mixins.json +++ b/src/main/resources/computercraft.mixins.json @@ -3,6 +3,7 @@ "package": "dan200.computercraft.fabric.mixin", "compatibilityLevel": "JAVA_16", "mixins": [ + "ConnectionAccess", "LevelResourceAccess", "MinecraftServerAccess",