Made head movement lock expire as soon as teleported
All checks were successful
build / build (push) Successful in 1m2s
All checks were successful
build / build (push) Successful in 1m2s
This commit is contained in:
@ -2,15 +2,39 @@ package wtf.hak.survivalfabric.mixin.client;
|
||||
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.network.packet.s2c.play.PositionFlag;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.lwjgl.system.CallbackI;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import wtf.hak.survivalfabric.teleportation.AngleViewHandler;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public abstract class EntityMixin {
|
||||
|
||||
private Vec3d lastPos = Vec3d.ZERO; // Store last position
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void onTick(CallbackInfo ci) {
|
||||
if((Entity) (Object) this instanceof ClientPlayerEntity player && player.isMainPlayer() && AngleViewHandler.PREVENT_HEAD_MOVEMENT) {
|
||||
if (!lastPos.equals(Vec3d.ZERO)) {
|
||||
double distance = player.getPos().distanceTo(lastPos);
|
||||
|
||||
if (distance > 5.0) {
|
||||
AngleViewHandler.PREVENT_HEAD_MOVEMENT = false;
|
||||
}
|
||||
}
|
||||
|
||||
lastPos = player.getPos();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "setYaw", at = @At("HEAD"), cancellable = true)
|
||||
private void preventYawChange(float yaw, CallbackInfo ci) {
|
||||
if((Object) this instanceof ClientPlayerEntity player) {
|
||||
|
Reference in New Issue
Block a user