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) {