Compare commits

...
2 Commits
Author SHA1 Message Date
Martin Robertz 4a11c18f99 update 2024-03-10 22:53:59 +01:00
slprimeandslprime 35b27ed27f Rotate to Near Block (#14)
Co-authored-by: slprime <[email protected]>
2024-03-10 22:52:53 +01:00
3 changed files with 27 additions and 4 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.18-GTNH:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.68:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.5.24-GTNH:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.97:dev')
}
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.14'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.16'
}
@@ -16,7 +16,7 @@ public class ClientFinderHelperUtils {
public static void rotateViewHelper(EntityClientPlayerMP player, List<ChunkPosition> targets) {
Vec3 playerVec = player.getPosition(1.0F);
Vec3 first = center(targets.get(0));
Vec3 first = center(getNearBlock(playerVec, targets));
AxisUtils.AxisPair pair = AxisUtils.calculateAxisPair(playerVec, first);
@@ -27,4 +27,27 @@ public class ClientFinderHelperUtils {
public static Vec3 center(ChunkPosition p) {
return Vec3.createVectorHelper(p.chunkPosX + 0.5, p.chunkPosY + 0.5, p.chunkPosZ + 0.5);
}
private static ChunkPosition getNearBlock(Vec3 player, List<ChunkPosition> targets) {
ChunkPosition result = null;
double minDistance = Double.MAX_VALUE;
for (ChunkPosition target : targets) {
double distance = getDistance(player, target);
if (distance < minDistance) {
result = target;
minDistance = distance;
}
}
return result;
}
private static double getDistance(Vec3 player, ChunkPosition target) {
double deltaX = target.chunkPosX - player.xCoord;
double deltaY = target.chunkPosY - player.yCoord;
double deltaZ = target.chunkPosZ - player.zCoord;
return Math.sqrt(deltaX * deltaX + deltaZ * deltaZ + deltaY * deltaY);
}
}