From e9b2f724c6fbf74cb97f44c44b7201256e83489e Mon Sep 17 00:00:00 2001 From: DrPerkyLegit Date: Sun, 31 May 2026 16:46:48 -0400 Subject: [PATCH 1/4] noPhysics field now works --- Minecraft.World/ArmorStand.cpp | 20 ++++++++++---------- Minecraft.World/ArmorStand.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Minecraft.World/ArmorStand.cpp b/Minecraft.World/ArmorStand.cpp index e83efe54..6056bc66 100644 --- a/Minecraft.World/ArmorStand.cpp +++ b/Minecraft.World/ArmorStand.cpp @@ -87,7 +87,7 @@ void ArmorStand::defineSynchedData() ArmorStand::~ArmorStand() {} - +bool ArmorStand::hasPhysics() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_NO_GRAVITY) == 0; } bool ArmorStand::isBaby() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_SMALL) != 0; } bool ArmorStand::isSmall() const { return isBaby(); } bool ArmorStand::isShowArms() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_SHOW_ARMS) != 0; } @@ -196,17 +196,17 @@ void ArmorStand::updateInvisibilityStatus() void ArmorStand::tick() { float lockedRot = this->yRot; - LivingEntity::tick(); + if (hasPhysics()) LivingEntity::tick(); if (onGround) { - BlockPos pos((int)floorf(x), (int)floorf(y) - 1, (int)floorf(z)); - int blockId = level->getTile(pos.getX(), pos.getY(), pos.getZ()); - if (blockId == Tile::topSnow->id) - { - int meta = level->getData(pos.getX(), pos.getY(), pos.getZ()); - float snowHeight = ((meta & 0x7) + 1) * 0.125f; - moveTo(x, floorf(y) + snowHeight, z, yRot, xRot); - } + BlockPos pos((int)floorf(x), (int)floorf(y) - 1, (int)floorf(z)); + int blockId = level->getTile(pos.getX(), pos.getY(), pos.getZ()); + if (blockId == Tile::topSnow->id) + { + int meta = level->getData(pos.getX(), pos.getY(), pos.getZ()); + float snowHeight = ((meta & 0x7) + 1) * 0.125f; + moveTo(x, floorf(y) + snowHeight, z, yRot, xRot); + } } this->yRot = lockedRot; this->yRotO = lockedRot; diff --git a/Minecraft.World/ArmorStand.h b/Minecraft.World/ArmorStand.h index 1e18cb47..60c751fe 100644 --- a/Minecraft.World/ArmorStand.h +++ b/Minecraft.World/ArmorStand.h @@ -68,6 +68,7 @@ public: explicit ArmorStand(Level* level); virtual ~ArmorStand(); + bool hasPhysics() const; bool isBaby() const; bool isSmall() const; bool isShowArms() const; From 31abba9e0413f1ddb3aa15cdcf486e8ab2e8b7bc Mon Sep 17 00:00:00 2001 From: DrPerkyLegit Date: Sun, 31 May 2026 17:21:14 -0400 Subject: [PATCH 2/4] Revert "noPhysics field now works" This reverts commit e9b2f724c6fbf74cb97f44c44b7201256e83489e. --- Minecraft.World/ArmorStand.cpp | 20 ++++++++++---------- Minecraft.World/ArmorStand.h | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Minecraft.World/ArmorStand.cpp b/Minecraft.World/ArmorStand.cpp index 6056bc66..e83efe54 100644 --- a/Minecraft.World/ArmorStand.cpp +++ b/Minecraft.World/ArmorStand.cpp @@ -87,7 +87,7 @@ void ArmorStand::defineSynchedData() ArmorStand::~ArmorStand() {} -bool ArmorStand::hasPhysics() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_NO_GRAVITY) == 0; } + bool ArmorStand::isBaby() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_SMALL) != 0; } bool ArmorStand::isSmall() const { return isBaby(); } bool ArmorStand::isShowArms() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_SHOW_ARMS) != 0; } @@ -196,17 +196,17 @@ void ArmorStand::updateInvisibilityStatus() void ArmorStand::tick() { float lockedRot = this->yRot; - if (hasPhysics()) LivingEntity::tick(); + LivingEntity::tick(); if (onGround) { - BlockPos pos((int)floorf(x), (int)floorf(y) - 1, (int)floorf(z)); - int blockId = level->getTile(pos.getX(), pos.getY(), pos.getZ()); - if (blockId == Tile::topSnow->id) - { - int meta = level->getData(pos.getX(), pos.getY(), pos.getZ()); - float snowHeight = ((meta & 0x7) + 1) * 0.125f; - moveTo(x, floorf(y) + snowHeight, z, yRot, xRot); - } + BlockPos pos((int)floorf(x), (int)floorf(y) - 1, (int)floorf(z)); + int blockId = level->getTile(pos.getX(), pos.getY(), pos.getZ()); + if (blockId == Tile::topSnow->id) + { + int meta = level->getData(pos.getX(), pos.getY(), pos.getZ()); + float snowHeight = ((meta & 0x7) + 1) * 0.125f; + moveTo(x, floorf(y) + snowHeight, z, yRot, xRot); + } } this->yRot = lockedRot; this->yRotO = lockedRot; diff --git a/Minecraft.World/ArmorStand.h b/Minecraft.World/ArmorStand.h index 60c751fe..1e18cb47 100644 --- a/Minecraft.World/ArmorStand.h +++ b/Minecraft.World/ArmorStand.h @@ -68,7 +68,6 @@ public: explicit ArmorStand(Level* level); virtual ~ArmorStand(); - bool hasPhysics() const; bool isBaby() const; bool isSmall() const; bool isShowArms() const; From a465d2239047969b8f070251740ed2caa2e34f21 Mon Sep 17 00:00:00 2001 From: DrPerkyLegit Date: Sun, 31 May 2026 17:23:50 -0400 Subject: [PATCH 3/4] Reapply "noPhysics field now works" This reverts commit 31abba9e0413f1ddb3aa15cdcf486e8ab2e8b7bc. --- Minecraft.World/ArmorStand.cpp | 20 ++++++++++---------- Minecraft.World/ArmorStand.h | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Minecraft.World/ArmorStand.cpp b/Minecraft.World/ArmorStand.cpp index e83efe54..6056bc66 100644 --- a/Minecraft.World/ArmorStand.cpp +++ b/Minecraft.World/ArmorStand.cpp @@ -87,7 +87,7 @@ void ArmorStand::defineSynchedData() ArmorStand::~ArmorStand() {} - +bool ArmorStand::hasPhysics() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_NO_GRAVITY) == 0; } bool ArmorStand::isBaby() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_SMALL) != 0; } bool ArmorStand::isSmall() const { return isBaby(); } bool ArmorStand::isShowArms() const { return (entityData->getByte(DATA_CLIENT_FLAGS) & FLAG_SHOW_ARMS) != 0; } @@ -196,17 +196,17 @@ void ArmorStand::updateInvisibilityStatus() void ArmorStand::tick() { float lockedRot = this->yRot; - LivingEntity::tick(); + if (hasPhysics()) LivingEntity::tick(); if (onGround) { - BlockPos pos((int)floorf(x), (int)floorf(y) - 1, (int)floorf(z)); - int blockId = level->getTile(pos.getX(), pos.getY(), pos.getZ()); - if (blockId == Tile::topSnow->id) - { - int meta = level->getData(pos.getX(), pos.getY(), pos.getZ()); - float snowHeight = ((meta & 0x7) + 1) * 0.125f; - moveTo(x, floorf(y) + snowHeight, z, yRot, xRot); - } + BlockPos pos((int)floorf(x), (int)floorf(y) - 1, (int)floorf(z)); + int blockId = level->getTile(pos.getX(), pos.getY(), pos.getZ()); + if (blockId == Tile::topSnow->id) + { + int meta = level->getData(pos.getX(), pos.getY(), pos.getZ()); + float snowHeight = ((meta & 0x7) + 1) * 0.125f; + moveTo(x, floorf(y) + snowHeight, z, yRot, xRot); + } } this->yRot = lockedRot; this->yRotO = lockedRot; diff --git a/Minecraft.World/ArmorStand.h b/Minecraft.World/ArmorStand.h index 1e18cb47..60c751fe 100644 --- a/Minecraft.World/ArmorStand.h +++ b/Minecraft.World/ArmorStand.h @@ -68,6 +68,7 @@ public: explicit ArmorStand(Level* level); virtual ~ArmorStand(); + bool hasPhysics() const; bool isBaby() const; bool isSmall() const; bool isShowArms() const; From 76000424e1d36305c67bb2a258abb38517f1c9b8 Mon Sep 17 00:00:00 2001 From: DrPerkyLegit Date: Sun, 31 May 2026 19:27:41 -0400 Subject: [PATCH 4/4] fix armor stands no gravity field --- Minecraft.World/ArmorStand.cpp | 90 +++++++++++++++++++++++++++++++++- Minecraft.World/ArmorStand.h | 2 + Minecraft.World/LivingEntity.h | 3 +- 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/Minecraft.World/ArmorStand.cpp b/Minecraft.World/ArmorStand.cpp index 6056bc66..81f6beca 100644 --- a/Minecraft.World/ArmorStand.cpp +++ b/Minecraft.World/ArmorStand.cpp @@ -16,6 +16,7 @@ #include "ParticleTypes.h" #include "Random.h" #include "AABB.h" +#include "../Minecraft.World/LevelChunk.h" const Rotations ArmorStand::DEFAULT_HEAD_POSE (0.0f, 0.0f, 0.0f); const Rotations ArmorStand::DEFAULT_BODY_POSE (0.0f, 0.0f, 0.0f); @@ -192,11 +193,98 @@ void ArmorStand::updateInvisibilityStatus() setInvisible(invisible); } +void ArmorStand::travel(float xa, float ya) +{ + if (hasPhysics()) { + float friction = 0.91f; + int frictionTile = 0; + if (onGround) + { + frictionTile = level->getTile(Mth::floor(x), Mth::floor(bb->y0) - 1, Mth::floor(z)); + friction = 0.6f * 0.91f; + if (frictionTile > 0) + { + friction = Tile::tiles[frictionTile]->friction * 0.91f; + } + } + + float friction2 = (0.6f * 0.6f * 0.91f * 0.91f * 0.6f * 0.91f) / (friction * friction * friction); + + float speed; + if (onGround) + { + speed = getSpeed() * friction2; + } + else + { + speed = flyingSpeed; + } + + moveRelative(xa, ya, speed); + + friction = 0.91f; + if (onGround) + { + friction = 0.6f * 0.91f; + if (frictionTile > 0) + { + friction = Tile::tiles[frictionTile]->friction * 0.91f; + } + } + if (onLadder()) + { + float max = 0.15f; + if (xd < -max) xd = -max; + if (xd > max) xd = max; + if (zd < -max) zd = -max; + if (zd > max) zd = max; + fallDistance = 0; + if (yd < -0.15) yd = -0.15; + bool playerSneaking = isSneaking() && this->instanceof(eTYPE_PLAYER); + if (playerSneaking && yd < 0) yd = 0; + } + + move(xd, yd, zd); + + if (horizontalCollision && onLadder()) + { + yd = 0.2; + } + + if (!level->isClientSide || (level->hasChunkAt(static_cast(x), 0, static_cast(z)) && level->getChunkAt(static_cast(x), static_cast(z))->loaded)) + { + yd -= 0.08; + } + else if (y > 0) + { + yd = -0.1; + } + else + { + yd = 0; + } + + yd *= 0.98f; + xd *= friction; + zd *= friction; + + walkAnimSpeedO = walkAnimSpeed; + double xxd = x - xo; + double zzd = z - zo; + float wst = Mth::sqrt(xxd * xxd + zzd * zzd) * 4; + if (wst > 1) wst = 1; + walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f; + walkAnimPos += walkAnimSpeed; + } else { + move(xd, yd, zd); + } +} + void ArmorStand::tick() { float lockedRot = this->yRot; - if (hasPhysics()) LivingEntity::tick(); + LivingEntity::tick(); if (onGround) { BlockPos pos((int)floorf(x), (int)floorf(y) - 1, (int)floorf(z)); diff --git a/Minecraft.World/ArmorStand.h b/Minecraft.World/ArmorStand.h index 60c751fe..eb2df737 100644 --- a/Minecraft.World/ArmorStand.h +++ b/Minecraft.World/ArmorStand.h @@ -147,6 +147,8 @@ public: void updateBoundingBox(bool markerMode); void updateInvisibilityStatus(); + virtual void travel(float xz, float ya); + virtual shared_ptr getCarriedItem() override; virtual shared_ptr getCarried(int slot) override; virtual shared_ptr getArmor(int pos) override; diff --git a/Minecraft.World/LivingEntity.h b/Minecraft.World/LivingEntity.h index cdce6701..6a3d6a50 100644 --- a/Minecraft.World/LivingEntity.h +++ b/Minecraft.World/LivingEntity.h @@ -51,9 +51,10 @@ public: static const int DATA_ARROW_COUNT_ID = 9; private: - BaseAttributeMap* attributes; CombatTracker* combatTracker; unordered_map activeEffects; +protected: + BaseAttributeMap* attributes; ItemInstanceArray lastEquipment; public: