Skip to content

Commit

Permalink
Add ability to disable glowing
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Nov 8, 2022
1 parent 6ff55ab commit b3da070
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<SynchedEntityData.DataItem<?>> 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<Byte> glowingTag = new SynchedEntityData.DataItem<>(EntityAccessor.getFLAGS(), flags);
trackedValues.add(glowingTag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit b3da070

Please sign in to comment.