From 24d19d422d196b62ef5b2b160fd418944c902019 Mon Sep 17 00:00:00 2001 From: samolego <34912839+samolego@users.noreply.github.com> Date: Thu, 8 Feb 2024 14:12:19 +0100 Subject: [PATCH] skin layers working again --- .../taterzens/common/npc/TaterzenNPC.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java b/src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java index 9873a1c9d..ff9a424bf 100644 --- a/src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java +++ b/src/main/java/org/samo_lego/taterzens/common/npc/TaterzenNPC.java @@ -77,6 +77,7 @@ import static net.minecraft.world.InteractionHand.MAIN_HAND; import static org.samo_lego.taterzens.common.Taterzens.*; +import static org.samo_lego.taterzens.common.mixin.accessors.APlayer.getPLAYER_MODE_CUSTOMISATION; import static org.samo_lego.taterzens.common.util.TextUtil.errorText; import static org.samo_lego.taterzens.common.util.TextUtil.successText; @@ -591,7 +592,10 @@ public void broadcastProfileUpdates() { ChunkMap storage = manager.chunkMap; AEntityTrackerEntry trackerEntry = ((AChunkMap) storage).getEntityMap().get(this.getId()); if (trackerEntry != null) { - trackerEntry.getSeenBy().forEach(tracking -> trackerEntry.getPlayer().addPairing(tracking.getPlayer())); + trackerEntry.getSeenBy().forEach(tracking -> { + trackerEntry.getPlayer().removePairing(tracking.getPlayer()); + trackerEntry.getPlayer().addPairing(tracking.getPlayer()); + }); } } @@ -1008,8 +1012,9 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { // As weird as it sounds, this gets triggered twice, first time with the item stack player is holding // then with "air" if fake type is player / armor stand - if (lastAction - ipl.getLastInteractionTime() < 50) + if (lastAction - ipl.getLastInteractionTime() < 50) { return InteractionResult.FAIL; + } ipl.setLastInteraction(lastAction); @@ -1033,6 +1038,7 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { // Updating behaviour (if npc had a sword and now has a bow, it won't // be able to attack otherwise.) this.setBehaviour(this.npcData.behaviour); + return InteractionResult.PASS; } else if ( player.getItemInHand(hand).getItem().equals(Items.POTATO) && @@ -1882,18 +1888,24 @@ public EntityType getPolymerEntityType(ServerPlayer player) { @Override public void modifyRawTrackedData(List> data, ServerPlayer player, boolean initial) { - // Change game profile + skin layers + // Fake selection glow ((ITaterzenEditor) player).getSelectedNpc().ifPresent(npc -> { if (this == npc && config.glowSelectedNpc) { - data.removeIf(value -> value.id() == 7); + data.removeIf(value -> value.id() == Entity.DATA_SHARED_FLAGS_ID.getId()); // Modify Taterzen to have fake glowing effect for the player - var flags = this.entityData.get(Entity.DATA_SHARED_FLAGS_ID); + byte flags = this.entityData.get(Entity.DATA_SHARED_FLAGS_ID); flags = (byte) (flags | 1 << Entity.FLAG_GLOWING); SynchedEntityData.DataValue glowingTag = SynchedEntityData.DataValue.create(Entity.DATA_SHARED_FLAGS_ID, flags); data.add(glowingTag); } }); + + // Skin layer settings + data.removeIf(value -> value.id() == getPLAYER_MODE_CUSTOMISATION().getId()); + + SynchedEntityData.DataValue skinLayerTag = SynchedEntityData.DataValue.create(getPLAYER_MODE_CUSTOMISATION(), this.npcData.skinLayers); + data.add(skinLayerTag); } @Override