Simplify LookBehaviorUtils's reachableCenter method
This commit is contained in:
parent
ef3c9999c8
commit
4ea4e5fa43
@ -70,7 +70,7 @@ public final class LookBehaviorUtils implements Helper {
|
||||
double xDiff = aabb.minX * sideOffset.x + aabb.maxX * (1 - sideOffset.x);
|
||||
double yDiff = aabb.minY * sideOffset.y + aabb.maxY * (1 - sideOffset.y);
|
||||
double zDiff = aabb.minZ * sideOffset.z + aabb.maxZ * (1 - sideOffset.z);
|
||||
possibleRotation = reachableRotation(pos, new Vec3d(pos).add(xDiff, yDiff, zDiff));
|
||||
possibleRotation = reachableOffset(pos, new Vec3d(pos).add(xDiff, yDiff, zDiff));
|
||||
if (possibleRotation.isPresent())
|
||||
return possibleRotation;
|
||||
}
|
||||
@ -96,7 +96,7 @@ public final class LookBehaviorUtils implements Helper {
|
||||
* @param offsetPos
|
||||
* @return
|
||||
*/
|
||||
protected static Optional<Rotation> reachableRotation(BlockPos pos, Vec3d offsetPos) {
|
||||
protected static Optional<Rotation> reachableOffset(BlockPos pos, Vec3d offsetPos) {
|
||||
Rotation rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), offsetPos);
|
||||
RayTraceResult result = rayTraceTowards(rotation);
|
||||
if (result != null
|
||||
@ -113,13 +113,7 @@ public final class LookBehaviorUtils implements Helper {
|
||||
* @return
|
||||
*/
|
||||
protected static Optional<Rotation> reachableCenter(BlockPos pos) {
|
||||
Rotation rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F), Utils.calcCenterFromCoords(pos, mc.world));
|
||||
RayTraceResult result = rayTraceTowards(rotation);
|
||||
if (result != null
|
||||
&& result.typeOfHit == RayTraceResult.Type.BLOCK
|
||||
&& result.getBlockPos().equals(pos))
|
||||
return Optional.of(rotation);
|
||||
return Optional.empty();
|
||||
return reachableOffset(pos, Utils.calcCenterFromCoords(pos, mc.world));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,9 +79,11 @@ public final class Utils {
|
||||
double xDiff = (bbox.minX + bbox.maxX) / 2;
|
||||
double yDiff = (bbox.minY + bbox.maxY) / 2;
|
||||
double zDiff = (bbox.minZ + bbox.maxZ) / 2;
|
||||
return new Vec3d(orig.getX() + xDiff,
|
||||
return new Vec3d(
|
||||
orig.getX() + xDiff,
|
||||
orig.getY() + yDiff,
|
||||
orig.getZ() + zDiff);
|
||||
orig.getZ() + zDiff
|
||||
);
|
||||
}
|
||||
|
||||
public static Vec3d getBlockPosCenter(BlockPos pos) {
|
||||
|
Loading…
Reference in New Issue
Block a user