From 5d54c63569761a8d06d5047a123f740b5bebcb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 15 Jan 2022 19:40:14 +0100 Subject: [PATCH] Remove obsolete overhead in fake player init. --- .../cil/oc2/common/util/FakePlayerUtils.java | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/main/java/li/cil/oc2/common/util/FakePlayerUtils.java b/src/main/java/li/cil/oc2/common/util/FakePlayerUtils.java index 5139c7d7..bd3f8fe1 100644 --- a/src/main/java/li/cil/oc2/common/util/FakePlayerUtils.java +++ b/src/main/java/li/cil/oc2/common/util/FakePlayerUtils.java @@ -1,22 +1,13 @@ package li.cil.oc2.common.util; import com.mojang.authlib.GameProfile; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; import li.cil.oc2.api.API; import li.cil.oc2.common.Config; -import net.minecraft.network.Connection; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.PacketFlow; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.network.ServerGamePacketListenerImpl; import net.minecraft.world.entity.Entity; -import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayerFactory; -import javax.annotation.Nullable; - public final class FakePlayerUtils { private static final String FAKE_PLAYER_NAME = "[" + API.MOD_ID + "]"; @@ -33,26 +24,6 @@ public static ServerPlayer getFakePlayer(final ServerLevel level, final Entity e } public static ServerPlayer getFakePlayer(final ServerLevel level) { - final FakePlayer player = FakePlayerFactory.get(level, new GameProfile(Config.fakePlayerUUID, FAKE_PLAYER_NAME)); - - // We need to give our fake player a fake network handler because some events we want - // to use the fake player with will unconditionally access this field. - if (player.connection == null) { - player.connection = new FakeServerPlayNetHandler(player); - } - - return player; - } - - /////////////////////////////////////////////////////////////////// - - private static class FakeServerPlayNetHandler extends ServerGamePacketListenerImpl { - public FakeServerPlayNetHandler(final FakePlayer fakePlayer) { - super(fakePlayer.server, new Connection(PacketFlow.CLIENTBOUND), fakePlayer); - } - - @Override - public void send(final Packet packetIn, @Nullable final GenericFutureListener> futureListeners) { - } + return FakePlayerFactory.get(level, new GameProfile(Config.fakePlayerUUID, FAKE_PLAYER_NAME)); } }