Armorstand bugfixes #2

This commit is contained in:
Lord Cambion 2026-03-16 16:56:50 +01:00
parent 885d346dd5
commit 257b3a6308
3 changed files with 54 additions and 26 deletions

View file

@ -80,6 +80,9 @@ void ArmorStand::defineSynchedData()
void ArmorStand::tick() void ArmorStand::tick()
{ {
float lockedRot = this->yRot; float lockedRot = this->yRot;
if (this->isInWater()|| this->isInLava()) {
this->yd -= 0.0392;
}
LivingEntity::tick(); LivingEntity::tick();
this->yRot = lockedRot; this->yRot = lockedRot;
this->yRotO = lockedRot; this->yRotO = lockedRot;
@ -87,6 +90,8 @@ void ArmorStand::tick()
this->yBodyRotO = lockedRot; this->yBodyRotO = lockedRot;
this->yHeadRot = lockedRot; this->yHeadRot = lockedRot;
this->yHeadRotO = lockedRot; this->yHeadRotO = lockedRot;
} }
bool ArmorStand::interact(shared_ptr<Player> player) bool ArmorStand::interact(shared_ptr<Player> player)
@ -142,50 +147,61 @@ bool ArmorStand::interact(shared_ptr<Player> player)
return true; return true;
} }
} }
bool ArmorStand::hurt(DamageSource *source, float damage) bool ArmorStand::hurt(DamageSource *source, float damage)
{ {
if (isInvulnerable()) return false; if (isInvulnerable() || level->isClientSide || removed || isMarker()) return false;
if (level->isClientSide || removed) return false;
if (isMarker()) return false;
if (dynamic_cast<EntityDamageSource *>(source) != nullptr)
{ if (source != nullptr && source->getMsgId() == eEntityDamageType_Suffocate) return false;
bool isFireDamage = source->isFire();
if (dynamic_cast<EntityDamageSource *>(source) != nullptr) {
shared_ptr<Entity> attacker = source->getEntity(); shared_ptr<Entity> attacker = source->getEntity();
if (attacker != nullptr && attacker->instanceof(eTYPE_PLAYER)) if (attacker != nullptr && attacker->instanceof(eTYPE_PLAYER)) {
{ if (dynamic_pointer_cast<Player>(attacker)->abilities.instabuild) {
shared_ptr<Player> player = dynamic_pointer_cast<Player>(attacker);
if (player->abilities.instabuild)
{
level->broadcastEntityEvent(shared_from_this(), (byte)31); level->broadcastEntityEvent(shared_from_this(), (byte)31);
remove(); remove();
return true; return true;
} }
} }
} }
long long now = (long long)tickCount; long long now = (long long)tickCount;
if (now - lastHit > 5)
{
if (isFireDamage) {
float currentHealth = this->getHealth() - 0.1f;
this->setHealth(currentHealth);
if (currentHealth <= 0) {
//level->broadcastEntityEvent(shared_from_this(), (byte)31);
remove();
return true;
}
return false;
}
if (now - lastHit > 5) {
level->broadcastEntityEvent(shared_from_this(), (byte)32); level->broadcastEntityEvent(shared_from_this(), (byte)32);
lastHit = now; lastHit = now;
} return true;
else } else {
{
level->broadcastEntityEvent(shared_from_this(), (byte)31); level->broadcastEntityEvent(shared_from_this(), (byte)31);
remove(); remove();
spawnAtLocation(Item::armor_stand_Id, 1); spawnAtLocation(Item::armor_stand_Id, 1);
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (equipment[i] != nullptr) { if (equipment[i] != nullptr) spawnAtLocation(equipment[i], 0.0f);
spawnAtLocation(equipment[i], 0.0f);
}
} }
return true;
} }
return true;
} }
bool ArmorStand::isPickable() bool ArmorStand::isPickable()
@ -428,3 +444,10 @@ void ArmorStand::handleEntityEvent(byte id)
else else
LivingEntity::handleEntityEvent(id); LivingEntity::handleEntityEvent(id);
} }
bool ArmorStand::updateInWaterState()
{
return Entity::updateInWaterState();
}

View file

@ -97,6 +97,9 @@ public:
virtual wstring getAName() override { return L""; } virtual wstring getAName() override { return L""; }
virtual wstring getDisplayName() override { return L""; } virtual wstring getDisplayName() override { return L""; }
virtual wstring getNetworkName() override { return L""; } virtual wstring getNetworkName() override { return L""; }
virtual bool isInWall() override { return false; }
virtual shared_ptr<ItemInstance> getCarriedItem() override; virtual shared_ptr<ItemInstance> getCarriedItem() override;
virtual shared_ptr<ItemInstance> getCarried(int slot) override; virtual shared_ptr<ItemInstance> getCarried(int slot) override;
@ -108,6 +111,8 @@ public:
virtual void addAdditonalSaveData(CompoundTag *tag) override; virtual void addAdditonalSaveData(CompoundTag *tag) override;
virtual void handleEntityEvent(byte eventId) override; virtual void handleEntityEvent(byte eventId) override;
virtual bool updateInWaterState() override;
protected: protected:
virtual void defineSynchedData() override; virtual void defineSynchedData() override;
virtual void registerAttributes() override; virtual void registerAttributes() override;

View file

@ -1030,7 +1030,7 @@ Recipes::Recipes()
L" S ", L" S ",
L"SXS", L"SXS",
L'S', Item::stick, L'S', Item::stick,
L'X',Tile::stoneSlabHalf, L'X', Tile::stoneSlabHalf,
L'D'); L'D');