From c196a81537610a3c550a9081712e53d1a5b530f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Paul=20S=C3=BCtterlin?=
<68386188+psu-de@users.noreply.github.com>
Date: Wed, 27 Mar 2024 20:05:25 +0100
Subject: [PATCH] added HorizontalLengthSquared() to Vector3 and fixed
MutableAABB return types
---
MineSharp.Core/Geometry/AABB.cs | 10 +++-------
MineSharp.Core/Geometry/Vector3.cs | 7 +++++++
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/MineSharp.Core/Geometry/AABB.cs b/MineSharp.Core/Geometry/AABB.cs
index ec311e37..a43e4cd2 100644
--- a/MineSharp.Core/Geometry/AABB.cs
+++ b/MineSharp.Core/Geometry/AABB.cs
@@ -201,7 +201,7 @@ public MutableAABB(double minX, double minY, double minZ, double maxX, double ma
/// Deflate this bounding box by , ,
/// Mutates this instance.
///
- public AABB Deflate(double x, double y, double z)
+ public MutableAABB Deflate(double x, double y, double z)
{
this.Min.Add(x, y, z);
this.Max.Add(-x, -y, -z);
@@ -212,7 +212,7 @@ public AABB Deflate(double x, double y, double z)
///
/// Expand this bounding box by x, y, z
///
- public AABB Expand(double x, double y, double z)
+ public MutableAABB Expand(double x, double y, double z)
{
if (x > 0)
this.Max.Add(x, 0, 0);
@@ -233,11 +233,7 @@ public AABB Expand(double x, double y, double z)
/// Offset this bounding box by , , .
/// Mutates this instance.
///
- ///
- ///
- ///
- ///
- public AABB Offset(double x, double y, double z)
+ public MutableAABB Offset(double x, double y, double z)
{
this.Min.Add(x, y, z);
this.Max.Add(x, y, z);
diff --git a/MineSharp.Core/Geometry/Vector3.cs b/MineSharp.Core/Geometry/Vector3.cs
index 85a2e4e9..c7224c0c 100644
--- a/MineSharp.Core/Geometry/Vector3.cs
+++ b/MineSharp.Core/Geometry/Vector3.cs
@@ -148,6 +148,13 @@ public double Length()
public double LengthSquared()
=> this.X * this.X + this.Y * this.Y + this.Z * this.Z;
+ ///
+ /// Calculates the squared horizontal (x, z) length of this vector instance
+ ///
+ [Pure]
+ public double HorizontalLengthSquared()
+ => this.X * this.X + this.Z * this.Z;
+
///
/// Calculates the horizontal squared length of this vector
///