mirror of
https://github.com/GTNewHorizons/FindIt.git
synced 2026-11-22 01:12:09 +00:00
[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:
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user