mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
Armorstand bugfixes #2
This commit is contained in:
parent
885d346dd5
commit
257b3a6308
|
|
@ -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)
|
|
||||||
{
|
|
||||||
shared_ptr<Entity> attacker = source->getEntity();
|
|
||||||
if (attacker != nullptr && attacker->instanceof(eTYPE_PLAYER))
|
|
||||||
{
|
|
||||||
shared_ptr<Player> player = dynamic_pointer_cast<Player>(attacker);
|
|
||||||
if (player->abilities.instabuild)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
level->broadcastEntityEvent(shared_from_this(), (byte)31);
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
if (attacker != nullptr && attacker->instanceof(eTYPE_PLAYER)) {
|
||||||
|
if (dynamic_pointer_cast<Player>(attacker)->abilities.instabuild) {
|
||||||
|
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()
|
||||||
|
|
@ -427,4 +443,11 @@ void ArmorStand::handleEntityEvent(byte id)
|
||||||
lastHit = (long long)tickCount;
|
lastHit = (long long)tickCount;
|
||||||
else
|
else
|
||||||
LivingEntity::handleEntityEvent(id);
|
LivingEntity::handleEntityEvent(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ArmorStand::updateInWaterState()
|
||||||
|
{
|
||||||
|
|
||||||
|
return Entity::updateInWaterState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -107,6 +110,8 @@ public:
|
||||||
virtual void readAdditionalSaveData(CompoundTag *tag) override;
|
virtual void readAdditionalSaveData(CompoundTag *tag) override;
|
||||||
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;
|
||||||
|
|
|
||||||
|
|
@ -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');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue