Compare commits

..
2 Commits
Author SHA1 Message Date
Martin Robertz 2961c8ad9e update 2024-03-03 09:57:20 +01:00
slprime 63b1fc85ec Rotate to Near Block 2024-03-02 20:48:49 +02: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.23-GTNH:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.84: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.15'
}
@@ -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);
}
}