mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-29 16:47:56 +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:
@@ -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 );
|
||||||
|
}
|
@@ -6,7 +6,9 @@
|
|||||||
package dan200.computercraft.shared.util;
|
package dan200.computercraft.shared.util;
|
||||||
|
|
||||||
import dan200.computercraft.api.turtle.FakePlayer;
|
import dan200.computercraft.api.turtle.FakePlayer;
|
||||||
|
import dan200.computercraft.fabric.mixin.ConnectionAccess;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.embedded.EmbeddedChannel;
|
||||||
import io.netty.util.concurrent.Future;
|
import io.netty.util.concurrent.Future;
|
||||||
import io.netty.util.concurrent.GenericFutureListener;
|
import io.netty.util.concurrent.GenericFutureListener;
|
||||||
import net.minecraft.network.Connection;
|
import net.minecraft.network.Connection;
|
||||||
@@ -283,6 +285,7 @@ public class FakeNetHandler extends ServerGamePacketListenerImpl
|
|||||||
FakeNetworkManager()
|
FakeNetworkManager()
|
||||||
{
|
{
|
||||||
super( PacketFlow.CLIENTBOUND );
|
super( PacketFlow.CLIENTBOUND );
|
||||||
|
((ConnectionAccess)this).setChannel( new EmbeddedChannel() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
"package": "dan200.computercraft.fabric.mixin",
|
"package": "dan200.computercraft.fabric.mixin",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
|
"ConnectionAccess",
|
||||||
"LevelResourceAccess",
|
"LevelResourceAccess",
|
||||||
"MinecraftServerAccess",
|
"MinecraftServerAccess",
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user