Compare commits
2 Commits
130b2db727
...
4e58bede4b
Author | SHA1 | Date | |
---|---|---|---|
4e58bede4b | |||
7db6d01869 |
@ -2,15 +2,39 @@ package wtf.hak.survivalfabric.mixin.client;
|
|||||||
|
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.entity.Entity;
|
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.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import wtf.hak.survivalfabric.teleportation.AngleViewHandler;
|
import wtf.hak.survivalfabric.teleportation.AngleViewHandler;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Mixin(Entity.class)
|
@Mixin(Entity.class)
|
||||||
public abstract class EntityMixin {
|
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)
|
@Inject(method = "setYaw", at = @At("HEAD"), cancellable = true)
|
||||||
private void preventYawChange(float yaw, CallbackInfo ci) {
|
private void preventYawChange(float yaw, CallbackInfo ci) {
|
||||||
if((Object) this instanceof ClientPlayerEntity player) {
|
if((Object) this instanceof ClientPlayerEntity player) {
|
||||||
|
Reference in New Issue
Block a user