Skip to content

Commit

Permalink
Check for fake players before sending hotbar message (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
Caedis authored Aug 6, 2024
1 parent 1e29ee4 commit 0d0d30d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public class MixinBlockBed {
value = "INVOKE",
target = "Lnet/minecraft/entity/player/EntityPlayer;addChatComponentMessage(Lnet/minecraft/util/IChatComponent;)V"))
public void hodgepodge$sendMessageAboveHotbar(EntityPlayer player, IChatComponent chatComponent) {
if (!(player instanceof EntityPlayerMP entityPlayerMP)) return;

GTNHLib.proxy.sendMessageAboveHotbar(
(EntityPlayerMP) player,
entityPlayerMP,
chatComponent.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE)),
60,
true,
Expand Down

2 comments on commit 0d0d30d

@mts2200
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Caedis FakePlayer are extends from EntityPlayerMP, that commit will nothing changed. You need to check for FakePlayer like this: https://github.com/gamerforEA/EventHelper/blob/1.7.10/src/main/java/com/gamerforea/eventhelper/util/FastUtils.java#L84-L97

@Lyfts
Copy link
Member

@Lyfts Lyfts commented on 0d0d30d Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't work as the fake player that this is guarding against does not extend EntityPlayerMP or FakePlayer. (Or rather it would work the exact same)

It isn't necessary to exclude normal FakePlayers in this instance and this check is sufficient.

Please sign in to comment.