aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/FlyingMob.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/FlyingMob.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/FlyingMob.cpp')
-rw-r--r--Minecraft.World/FlyingMob.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/Minecraft.World/FlyingMob.cpp b/Minecraft.World/FlyingMob.cpp
new file mode 100644
index 00000000..b7a01678
--- /dev/null
+++ b/Minecraft.World/FlyingMob.cpp
@@ -0,0 +1,81 @@
+#include "stdafx.h"
+#include "net.minecraft.world.level.h"
+#include "net.minecraft.world.level.tile.h"
+#include "net.minecraft.world.phys.h"
+#include "FlyingMob.h"
+
+FlyingMob::FlyingMob(Level *level) : Mob( level )
+{
+}
+
+void FlyingMob::causeFallDamage(float distance)
+{
+ // this method is empty because flying creatures should
+ // not trigger the "fallOn" tile calls (such as trampling crops)
+}
+
+void FlyingMob::travel(float xa, float ya)
+{
+ if (isInWater())
+ {
+ moveRelative(xa, ya, 0.02f);
+ move(xd, yd, zd);
+
+ xd *= 0.80f;
+ yd *= 0.80f;
+ zd *= 0.80f;
+ }
+ else if (isInLava())
+ {
+ moveRelative(xa, ya, 0.02f);
+ move(xd, yd, zd);
+ xd *= 0.50f;
+ yd *= 0.50f;
+ zd *= 0.50f;
+ }
+ else
+ {
+ float friction = 0.91f;
+ if (onGround)
+ {
+ friction = 0.6f * 0.91f;
+ int t = level->getTile( Mth::floor(x), Mth::floor(bb->y0) - 1, Mth::floor(z));
+ if (t > 0)
+ {
+ friction = Tile::tiles[t]->friction * 0.91f;
+ }
+ }
+
+ float friction2 = (0.6f * 0.6f * 0.91f * 0.91f * 0.6f * 0.91f) / (friction * friction * friction);
+ moveRelative(xa, ya, (onGround ? 0.1f * friction2 : 0.02f));
+
+ friction = 0.91f;
+ if (onGround)
+ {
+ friction = 0.6f * 0.91f;
+ int t = level->getTile( Mth::floor(x), Mth::floor(bb->y0) - 1, Mth::floor(z));
+ if (t > 0)
+ {
+ friction = Tile::tiles[t]->friction * 0.91f;
+ }
+ }
+
+ move(xd, yd, zd);
+
+ xd *= friction;
+ yd *= friction;
+ zd *= friction;
+ }
+ walkAnimSpeedO = walkAnimSpeed;
+ double xxd = x - xo;
+ double zzd = z - zo;
+ float wst = (float) sqrt(xxd * xxd + zzd * zzd) * 4;
+ if (wst > 1) wst = 1;
+ walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f;
+ walkAnimPos += walkAnimSpeed;
+}
+
+bool FlyingMob::onLadder()
+{
+ return false;
+} \ No newline at end of file