Fix initial entity rotation getting lost (fixes #619)
This fixes the rotation of already existing entities that just got sent to the client. Those get spawned with their rotation, which we didn't capture. This commit fixes that by initializing our tracked rotation to NaN and returning the original rotation until the tracked one is initialized (we do it this way rather than initializing during the spawn packet handling because there are many spawn packets, especially with modded, and we cannot possibly inject into all of them). This does not fix the rotation of newly placed entities (cause they seem to get spawned with 0/0 and then get teleported to their correct rotation). The previous commit fixed that case by capturing the rotation from the teleport packet.
This commit is contained in:
@@ -3,25 +3,32 @@ package com.replaymod.replay.mixin.entity_tracking;
|
||||
import com.replaymod.replay.ext.EntityExt;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class Mixin_EntityExt implements EntityExt {
|
||||
|
||||
@Unique
|
||||
private float trackedYaw;
|
||||
@Shadow
|
||||
public float yaw;
|
||||
|
||||
@Shadow
|
||||
public float pitch;
|
||||
|
||||
@Unique
|
||||
private float trackedPitch;
|
||||
private float trackedYaw = Float.NaN;
|
||||
|
||||
@Unique
|
||||
private float trackedPitch = Float.NaN;
|
||||
|
||||
@Override
|
||||
public float replaymod$getTrackedYaw() {
|
||||
return this.trackedYaw;
|
||||
return !Float.isNaN(this.trackedYaw) ? this.trackedYaw : this.yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float replaymod$getTrackedPitch() {
|
||||
return this.trackedPitch;
|
||||
return !Float.isNaN(this.trackedPitch) ? this.trackedPitch : this.pitch;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user