From b3da0703534e5747ce33cc13ec1e5659406b99e8 Mon Sep 17 00:00:00 2001 From: samolego <34912839+samolego@users.noreply.github.com> Date: Tue, 8 Nov 2022 12:05:40 +0100 Subject: [PATCH] Add ability to disable glowing --- ...erverGamePacketListenerImplMixin_PacketFaker.java | 12 ++++++------ .../org/samo_lego/taterzens/storage/TaterConfig.java | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java b/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java index 1c10e24f3..253ba7572 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java +++ b/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java @@ -115,28 +115,28 @@ private void changeEntityType(Packet packet, PacketSendListener listener, Cal // the client to fetch skin. // If player is immediately removed from the tablist, // client doesn't care about the skin. - if(config.taterzenTablistTimeout != -1) { + if (config.taterzenTablistTimeout != -1) { var uuid = npc.getGameProfile().getId(); taterzens$tablistQueue.remove(uuid); taterzens$tablistQueue.put(uuid, new NpcPlayerUpdate(npc.getGameProfile(), npc.getTabListName(), taterzens$queueTick + config.taterzenTablistTimeout)); } - this.connection.send(new ClientboundRotateHeadPacket(entity, (byte)((int)(entity.getYHeadRot() * 256.0F / 360.0F))), listener); + this.connection.send(new ClientboundRotateHeadPacket(entity, (byte) ((int) (entity.getYHeadRot() * 256.0F / 360.0F))), listener); ci.cancel(); - } else if(packet instanceof ClientboundSetEntityDataPacket) { + } else if (packet instanceof ClientboundSetEntityDataPacket) { Entity entity = world.getEntity(((ClientboundSetEntityDataPacketAccessor) packet).getEntityId()); - if(!(entity instanceof TaterzenNPC taterzen)) + if (!(entity instanceof TaterzenNPC taterzen)) return; Player fakePlayer = taterzen.getFakePlayer(); List> trackedValues = fakePlayer.getEntityData().getAll(); - if(taterzen.equals(((ITaterzenEditor) this.player).getNpc()) && trackedValues != null) { + if (taterzen.equals(((ITaterzenEditor) this.player).getNpc()) && trackedValues != null && config.glowSelectedNpc) { trackedValues.removeIf(value -> value.getAccessor().getId() == 0); Byte flags = fakePlayer.getEntityData().get(EntityAccessor.getFLAGS()); // Modify Taterzen to have fake glowing effect for the player - flags = (byte)(flags | 1 << EntityAccessor.getFLAG_GLOWING()); + flags = (byte) (flags | 1 << EntityAccessor.getFLAG_GLOWING()); SynchedEntityData.DataItem glowingTag = new SynchedEntityData.DataItem<>(EntityAccessor.getFLAGS(), flags); trackedValues.add(glowingTag); diff --git a/common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java b/common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java index 0c3eb6274..6f640aa30 100644 --- a/common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java +++ b/common/src/main/java/org/samo_lego/taterzens/storage/TaterConfig.java @@ -105,6 +105,13 @@ public class TaterConfig implements IBrigadierConfigurator { @SerializedName("combat_in_peaceful") public boolean combatInPeaceful = true; + + @SerializedName("// Whether give fake glowing effect to Taterzen when selected.") + public final String _comment_glowSelectedNpc = ""; + @BrigadierDescription(defaultOption = "true") + @SerializedName("glow_selected_npc") + public boolean glowSelectedNpc = true; + @Override public void save() { this.saveConfigFile(Taterzens.getInstance().getConfigFile());