0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-20 01:12:13 +02:00

Add RotationUtils.getAngleToLastReportedLookVec()

This commit is contained in:
Alexander01998 2019-08-03 23:13:50 +02:00
parent b05a72da36
commit 127a97b4f1
5 changed files with 50 additions and 1 deletions

View File

@ -8,6 +8,7 @@
package net.wurstclient.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -31,6 +32,11 @@ import net.wurstclient.mixinterface.IClientPlayerEntity;
public class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
implements IClientPlayerEntity
{
@Shadow
private float lastYaw;
@Shadow
private float lastPitch;
public ClientPlayerEntityMixin(WurstClient wurst, ClientWorld clientWorld_1,
GameProfile gameProfile_1)
{
@ -83,4 +89,16 @@ public class ClientPlayerEntityMixin extends AbstractClientPlayerEntity
{
this.noClip = noClip;
}
@Override
public float getLastYaw()
{
return lastYaw;
}
@Override
public float getLastPitch()
{
return lastPitch;
}
}

View File

@ -15,12 +15,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.WindowEventHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.util.NonBlockingThreadExecutor;
import net.minecraft.util.snooper.Snooper;
import net.minecraft.util.snooper.SnooperListener;
import net.wurstclient.WurstClient;
import net.wurstclient.events.LeftClickListener.LeftClickEvent;
import net.wurstclient.mixinterface.IClientPlayerEntity;
import net.wurstclient.mixinterface.IClientPlayerInteractionManager;
import net.wurstclient.mixinterface.IMinecraftClient;
@ -32,7 +34,9 @@ public class MinecraftClientMixin extends NonBlockingThreadExecutor<Runnable>
@Shadow
private int itemUseCooldown;
@Shadow
public ClientPlayerInteractionManager interactionManager;
private ClientPlayerInteractionManager interactionManager;
@Shadow
private ClientPlayerEntity player;
private MinecraftClientMixin(WurstClient wurst, String string_1)
{
@ -69,6 +73,12 @@ public class MinecraftClientMixin extends NonBlockingThreadExecutor<Runnable>
this.itemUseCooldown = itemUseCooldown;
}
@Override
public IClientPlayerEntity getPlayer()
{
return (IClientPlayerEntity)player;
}
@Override
public IClientPlayerInteractionManager getInteractionManager()
{

View File

@ -10,4 +10,8 @@ package net.wurstclient.mixinterface;
public interface IClientPlayerEntity
{
public void setNoClip(boolean noClip);
public float getLastYaw();
public float getLastPitch();
}

View File

@ -16,4 +16,6 @@ public interface IMinecraftClient
public IClientPlayerInteractionManager getInteractionManager();
public int getItemUseCooldown();
public IClientPlayerEntity getPlayer();
}

View File

@ -11,6 +11,7 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.wurstclient.WurstClient;
import net.wurstclient.mixinterface.IClientPlayerEntity;
public class RotationUtils
{
@ -52,6 +53,20 @@ public class RotationUtils
return new Rotation(yaw, pitch);
}
public static double getAngleToLastReportedLookVec(Vec3d vec)
{
Rotation needed = getNeededRotations(vec);
IClientPlayerEntity player = WurstClient.IMC.getPlayer();
float lastReportedYaw = MathHelper.wrapDegrees(player.getLastYaw());
float lastReportedPitch = MathHelper.wrapDegrees(player.getLastPitch());
float diffYaw = lastReportedYaw - needed.yaw;
float diffPitch = lastReportedPitch - needed.pitch;
return Math.sqrt(diffYaw * diffYaw + diffPitch * diffPitch);
}
public static final class Rotation
{
private final float yaw;