/
MixinEntityTrackerEntry.java
42 lines (31 loc) · 1.26 KB
/
MixinEntityTrackerEntry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.ishland.vmp.mixins.playerwatching.optimize_nearby_entity_tracking_lookups;
import com.ishland.vmp.common.playerwatching.EntityTrackerEntryExtension;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.EntityTrackerEntry;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@Mixin(EntityTrackerEntry.class)
public abstract class MixinEntityTrackerEntry implements EntityTrackerEntryExtension {
@Shadow private int trackingTick;
@Shadow @Final private int tickInterval;
@Shadow public abstract void tick();
@Shadow protected abstract void syncEntityData();
@Shadow @Final private Entity entity;
@Shadow private int updatesWithoutVehicle;
@Override
public void vmp$tickAlways() {
this.trackingTick = MathHelper.roundUpToMultiple(this.trackingTick, this.tickInterval);
this.updatesWithoutVehicle = 1 << 16;
this.entity.velocityDirty = true;
this.tick();
}
@Override
public void vmp$syncEntityData() {
trackingTick ++;
if (this.trackingTick % this.tickInterval == 0) { // [VanillaCopy]
this.syncEntityData();
}
}
}