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();