[QoF] Adding feature that automatically rotate player view when find a item/tile entity successfully (#12)

* init

* Configuration & Separating lookAtTarget()

* Spotless

* Move to center
This commit is contained in:
gitboy14 authored and GitHub committed 2024-02-17 02:04:21 -06:00
1 parent f1313bfc48
commit 0c2a7beed9
5 files changed
+94

No files matched your search

@@ -0,0 +1,35 @@
package com.gtnh.findit.util;
import java.util.List;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkPosition;
import com.gtnh.findit.service.blockfinder.BlockFoundResponse;
import com.gtnh.findit.service.itemfinder.ItemFoundResponse;
public class ClientFinderHelperUtils {
public static void lookAtTarget(EntityClientPlayerMP player, ItemFoundResponse response) {
rotateViewHelper(player, response.getPositions());
}
public static void lookAtTarget(EntityClientPlayerMP player, BlockFoundResponse response) {
rotateViewHelper(player, response.getPositions());
}
public static void rotateViewHelper(EntityClientPlayerMP player, List<ChunkPosition> targets) {
Vec3 playerVec = player.getPosition(1.0F);
Vec3 first = center(targets.remove(0));
AxisUtils.AxisPair pair = AxisUtils.calculateAxisPair(playerVec, first);
player.rotationYaw = pair.yaw();
player.rotationPitch = pair.pitch();
}
public static Vec3 center(ChunkPosition p) {
return Vec3.createVectorHelper(p.chunkPosX + 0.5, p.chunkPosY + 0.5, p.chunkPosZ + 0.5);
}
}