Skip to content

Commit

Permalink
🐛 Don't disable EntityTracker updates for vanilal entities
Browse files Browse the repository at this point in the history
  • Loading branch information
skerit committed Jul 5, 2024
1 parent 57d4972 commit b871b7f
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -124,6 +127,8 @@ private void preventSyncEntityData(CallbackInfo ci) {
filteredView.sendBatched();
});

if (!hasValidWizard.get()) return;

if (this.entity instanceof LivingEntity livingEntity) {
Set<EntityAttributeInstance> set = ((LivingEntity)this.entity).getAttributes().getTracked();
set.clear();
Expand Down

0 comments on commit b871b7f

Please sign in to comment.