|
| 1 | +package dev.isxander.debugify.mixins.basic.mc44654; |
| 2 | + |
| 3 | +import dev.isxander.debugify.fixes.BugFix; |
| 4 | +import dev.isxander.debugify.fixes.FixCategory; |
| 5 | +import net.minecraft.world.entity.Entity; |
| 6 | +import net.minecraft.world.entity.EntityType; |
| 7 | +import org.spongepowered.asm.mixin.Mixin; |
| 8 | +import org.spongepowered.asm.mixin.Shadow; |
| 9 | +import org.spongepowered.asm.mixin.injection.At; |
| 10 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 11 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 12 | + |
| 13 | +@BugFix(id = "MC-44654", category = FixCategory.BASIC, env = BugFix.Env.SERVER, description = "Some entities don't update position to the client when teleported") |
| 14 | +@Mixin(Entity.class) |
| 15 | +public abstract class EntityMixin { |
| 16 | + @Shadow |
| 17 | + public abstract EntityType<?> getType(); |
| 18 | + |
| 19 | + @Shadow |
| 20 | + public boolean hasImpulse; |
| 21 | + |
| 22 | + /** |
| 23 | + * Since the update interval is set to infinity, the position will never get updated. |
| 24 | + * To fix, we mark velocity as dirty via hasImpulse to force an update. |
| 25 | + * |
| 26 | + * We inject precisely here as the target is only called when `!firstTick && isServerLevel`, |
| 27 | + * since this is where the issue occurs. |
| 28 | + */ |
| 29 | + @Inject(method = "setPosRaw", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;isRemoved()Z")) |
| 30 | + private void forceClientUpdate(CallbackInfo ci) { |
| 31 | + if (this.getType().updateInterval() == Integer.MAX_VALUE) { |
| 32 | + this.hasImpulse = true; |
| 33 | + } |
| 34 | + } |
| 35 | +} |
0 commit comments