From f8468b8862371c29c23fd90643eaf76ace67e1de Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Wed, 15 Jun 2022 17:04:41 -0400 Subject: [PATCH] show skins for real for real this time --- .../entity/BlockEntityStoredPlayerImpetus.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java index 076f4ffe..aef5bf48 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/entity/BlockEntityStoredPlayerImpetus.java @@ -31,6 +31,9 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus { private GameProfile storedPlayerProfile = null; private UUID storedPlayer = null; + private GameProfile cachedDisplayProfile = null; + private ItemStack cachedDisplayStack = null; + public BlockEntityStoredPlayerImpetus(BlockPos pWorldPosition, BlockState pBlockState) { super(HexBlockEntities.IMPETUS_STOREDPLAYER_TILE, pWorldPosition, pBlockState); } @@ -84,10 +87,15 @@ public class BlockEntityStoredPlayerImpetus extends BlockEntityAbstractImpetus { var name = this.getPlayerName(); if (name != null) { - var head = new ItemStack(Items.PLAYER_HEAD); - NBTHelper.put(head, "SkullOwner", NbtUtils.writeGameProfile(new CompoundTag(), name)); - lines.add( - new Pair<>(head, new TranslatableComponent("hexcasting.tooltip.lens.impetus.storedplayer", name.getName()))); + if (!name.equals(cachedDisplayProfile) || cachedDisplayStack == null) { + cachedDisplayProfile = name; + var head = new ItemStack(Items.PLAYER_HEAD); + NBTHelper.put(head, "SkullOwner", NbtUtils.writeGameProfile(new CompoundTag(), name)); + head.getItem().verifyTagAfterLoad(head.getOrCreateTag()); + cachedDisplayStack = head; + } + lines.add(new Pair<>(cachedDisplayStack, + new TranslatableComponent("hexcasting.tooltip.lens.impetus.storedplayer", name.getName()))); } else { lines.add(new Pair<>(new ItemStack(Items.BARRIER), new TranslatableComponent("hexcasting.tooltip.lens.impetus.storedplayer.none")));