Compare commits

..
2 Commits
Author SHA1 Message Date
Martin Robertz 9d6ce05d9e update 2024-02-17 10:02:56 +01:00
gitboy14 0c2a7beed9 [QoF] Adding feature that automatically rotate player view when find a item/tile entity successfully (#12)
* init

* Configuration & Separating lookAtTarget()

* Spotless

* Move to center
2024-02-17 02:04:21 -06:00
3 changed files with 11 additions and 8 deletions

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
// Add your dependencies here
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.17-GTNH:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.64:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.18-GTNH:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.68:dev')
}
@@ -1,7 +1,6 @@
package com.gtnh.findit.util;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkPosition;
public class AxisUtils {
@@ -24,10 +23,10 @@ public class AxisUtils {
}
}
public static AxisPair calculateAxisPair(Vec3 player, ChunkPosition target) {
double deltaX = target.chunkPosX - player.xCoord;
double deltaY = target.chunkPosY - player.yCoord;
double deltaZ = target.chunkPosZ - player.zCoord;
public static AxisPair calculateAxisPair(Vec3 player, Vec3 target) {
double deltaX = target.xCoord - player.xCoord;
double deltaY = target.yCoord - player.yCoord;
double deltaZ = target.zCoord - player.zCoord;
double distanceXZ = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
@@ -21,11 +21,15 @@ public class ClientFinderHelperUtils {
public static void rotateViewHelper(EntityClientPlayerMP player, List<ChunkPosition> targets) {
Vec3 playerVec = player.getPosition(1.0F);
ChunkPosition first = targets.remove(0);
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);
}
}