From 308cc67c9bb5290a2a285f4b0b3be3a0b77b3997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Fabi=C3=A1nek?= Date: Sun, 10 Dec 2023 16:19:48 +0100 Subject: [PATCH] Fixed server --- .../friendsandfoes/util/client/PlayerProvider.java | 14 ++++++++++++++ .../platform/forge/PacketChannelManagerImpl.java | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/com/faboslav/friendsandfoes/util/client/PlayerProvider.java diff --git a/common/src/main/java/com/faboslav/friendsandfoes/util/client/PlayerProvider.java b/common/src/main/java/com/faboslav/friendsandfoes/util/client/PlayerProvider.java new file mode 100644 index 000000000..e10a9f97e --- /dev/null +++ b/common/src/main/java/com/faboslav/friendsandfoes/util/client/PlayerProvider.java @@ -0,0 +1,14 @@ +package com.faboslav.friendsandfoes.util.client; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.entity.player.PlayerEntity; + +public final class PlayerProvider +{ + public static PlayerEntity getClientPlayer() { + return MinecraftClient.getInstance().player; + } + + private PlayerProvider() { + } +} diff --git a/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/PacketChannelManagerImpl.java b/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/PacketChannelManagerImpl.java index f914759e4..016f12f7d 100644 --- a/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/PacketChannelManagerImpl.java +++ b/forge/src/main/java/com/faboslav/friendsandfoes/platform/forge/PacketChannelManagerImpl.java @@ -3,7 +3,7 @@ import com.faboslav.friendsandfoes.network.base.Packet; import com.faboslav.friendsandfoes.network.base.PacketHandler; import com.faboslav.friendsandfoes.platform.ModVersion; -import net.minecraft.client.MinecraftClient; +import com.faboslav.friendsandfoes.util.client.PlayerProvider; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; @@ -47,7 +47,7 @@ public static > void registerS2CPacket( NetworkEvent.Context context = ctx.get(); PlayerEntity player = null; if (context.getSender() == null) { - player = MinecraftClient.getInstance().player; + player = PlayerProvider.getClientPlayer(); } if (player != null) {