aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/EntityPos.cpp
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/EntityPos.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/EntityPos.cpp')
-rw-r--r--Minecraft.World/EntityPos.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/Minecraft.World/EntityPos.cpp b/Minecraft.World/EntityPos.cpp
new file mode 100644
index 00000000..38b50573
--- /dev/null
+++ b/Minecraft.World/EntityPos.cpp
@@ -0,0 +1,62 @@
+#include "stdafx.h"
+#include "Entity.h"
+#include "EntityPos.h"
+
+EntityPos::EntityPos(double x, double y, double z, float yRot, float xRot)
+{
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ this->yRot = yRot;
+ this->xRot = xRot;
+ rot = true;
+ move = true;
+}
+
+EntityPos::EntityPos(double x, double y, double z)
+{
+ yRot = xRot = 0.0f;
+
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ move = true;
+ rot = false;
+}
+
+EntityPos::EntityPos(float yRot, float xRot)
+{
+ x = y = z = 0.0;
+
+ this->yRot = yRot;
+ this->xRot = xRot;
+ rot = true;
+ move = false;
+}
+
+EntityPos *EntityPos::lerp(shared_ptr<Entity> e, float f)
+{
+ double xd = e->x+(x-e->x)*f;
+ double yd = e->y+(y-e->y)*f;
+ double zd = e->z+(z-e->z)*f;
+
+ float yrdd = Mth::wrapDegrees(yRot - e->yRot);
+ float xrdd = Mth::wrapDegrees(xRot - e->xRot);
+
+ float yrd = Mth::wrapDegrees(e->yRot + yrdd * f);
+ float xrd = Mth::wrapDegrees(e->xRot + xrdd * f);
+
+ if (rot && move)
+ {
+ return new EntityPos(xd, yd, zd, yrd, xrd);
+ }
+ if (move)
+ {
+ return new EntityPos(xd, yd, zd);
+ }
+ if (rot)
+ {
+ return new EntityPos(yrd, xrd);
+ }
+ return NULL;
+} \ No newline at end of file