From b871b7f60648d24ba45e10ca3df5da949c79915e Mon Sep 17 00:00:00 2001 From: Jelle De Loecker Date: Fri, 5 Jul 2024 15:12:22 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Don't=20disable=20EntityTracker?= =?UTF-8?q?=20updates=20for=20vanilal=20entities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../polymc/mixins/entity/EntityTrackerEntryMixin.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/theepicblock/polymc/mixins/entity/EntityTrackerEntryMixin.java b/src/main/java/io/github/theepicblock/polymc/mixins/entity/EntityTrackerEntryMixin.java index 56d689a3..8b7e20d2 100644 --- a/src/main/java/io/github/theepicblock/polymc/mixins/entity/EntityTrackerEntryMixin.java +++ b/src/main/java/io/github/theepicblock/polymc/mixins/entity/EntityTrackerEntryMixin.java @@ -26,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; @Mixin(EntityTrackerEntry.class) public class EntityTrackerEntryMixin implements EntityTrackerEntryDuck { @@ -108,11 +109,13 @@ private void preventSyncEntityData(CallbackInfo ci) { if (wizards.isEmpty()) return; + AtomicBoolean hasValidWizard = new AtomicBoolean(false); wizards.forEach((polyMap, wizard) -> { - var allPlayers = PolyMapFilteredPlayerView.getAll(world, this.entity.getBlockPos()); if (!(wizard instanceof EntityWizard entityWizard)) return; + hasValidWizard.set(true); + var allPlayers = PolyMapFilteredPlayerView.getAll(world, this.entity.getBlockPos()); var filteredView = new PolyMapFilteredPlayerView(allPlayers, polyMap); try { @@ -124,6 +127,8 @@ private void preventSyncEntityData(CallbackInfo ci) { filteredView.sendBatched(); }); + if (!hasValidWizard.get()) return; + if (this.entity instanceof LivingEntity livingEntity) { Set set = ((LivingEntity)this.entity).getAttributes().getTracked(); set.clear();