diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/HangingEntity.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/HangingEntity.cpp')
| -rw-r--r-- | Minecraft.World/HangingEntity.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/Minecraft.World/HangingEntity.cpp b/Minecraft.World/HangingEntity.cpp index 6256a381..8ba3e1fc 100644 --- a/Minecraft.World/HangingEntity.cpp +++ b/Minecraft.World/HangingEntity.cpp @@ -14,22 +14,19 @@ void HangingEntity::_init(Level *level) checkInterval = 0; dir = 0; xTile = yTile = zTile = 0; + this->heightOffset = 0; + this->setSize(0.5f, 0.5f); } HangingEntity::HangingEntity(Level *level) : Entity( level ) { _init(level); - this->heightOffset = 0; - this->setSize(0.5f, 0.5f); } HangingEntity::HangingEntity(Level *level, int xTile, int yTile, int zTile, int dir) : Entity( level ) { _init(level); - //motive = NULL; - this->heightOffset = 0; - this->setSize(0.5f, 0.5f); this->xTile = xTile; this->yTile = yTile; this->zTile = zTile; @@ -38,7 +35,7 @@ HangingEntity::HangingEntity(Level *level, int xTile, int yTile, int zTile, int void HangingEntity::setDir(int dir) { this->dir = dir; - this->yRotO = this->yRot = (float)(dir * 90); + yRotO = yRot = (float)(dir * 90); float w = (float)getWidth(); float h = (float)getHeight(); @@ -75,7 +72,7 @@ void HangingEntity::setDir(int dir) if (dir == Direction::EAST) z -= offs(getWidth()); y += offs(getHeight()); - this->setPos(x, y, z); + setPos(x, y, z); float ss = -(0.5f / 16.0f); @@ -98,13 +95,16 @@ float HangingEntity::offs(int w) void HangingEntity::tick() { - if (checkInterval++ == 20 * 5 && !level->isClientSide)//isClientSide) + xo = x; + yo = y; + zo = z; + if (checkInterval++ == 20 * 5 && !level->isClientSide) { checkInterval = 0; if (!removed && !survives()) { remove(); - dropItem(); + dropItem(nullptr); } } } @@ -156,7 +156,7 @@ bool HangingEntity::survives() for (AUTO_VAR(it, entities->begin()); it != itEnd; it++) { shared_ptr<Entity> e = (*it); - if(dynamic_pointer_cast<HangingEntity>(e) != NULL) + if( e->instanceof(eTYPE_HANGING_ENTITY) ) { return false; } @@ -181,15 +181,16 @@ bool HangingEntity::skipAttackInteraction(shared_ptr<Entity> source) return false; } -bool HangingEntity::hurt(DamageSource *source, int damage) +bool HangingEntity::hurt(DamageSource *source, float damage) { + if (isInvulnerable()) return false; if (!removed && !level->isClientSide) { if (dynamic_cast<EntityDamageSource *>(source) != NULL) { shared_ptr<Entity> sourceEntity = source->getDirectEntity(); - if (dynamic_pointer_cast<Player>(sourceEntity) != NULL && !dynamic_pointer_cast<Player>(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) ) + if ( (sourceEntity != NULL) && sourceEntity->instanceof(eTYPE_PLAYER) && !dynamic_pointer_cast<Player>(sourceEntity)->isAllowedToHurtEntity(shared_from_this()) ) { return false; } @@ -200,7 +201,7 @@ bool HangingEntity::hurt(DamageSource *source, int damage) shared_ptr<Player> player = nullptr; shared_ptr<Entity> e = source->getEntity(); - if (e!=NULL && ((e->GetType() & eTYPE_PLAYER)!=0) ) // check if it's serverplayer or player + if ( (e!=NULL) && e->instanceof(eTYPE_PLAYER) ) // check if it's serverplayer or player { player = dynamic_pointer_cast<Player>( e ); } @@ -210,7 +211,7 @@ bool HangingEntity::hurt(DamageSource *source, int damage) return true; } - dropItem(); + dropItem(nullptr); } return true; } @@ -221,7 +222,7 @@ void HangingEntity::move(double xa, double ya, double za, bool noEntityCubes) if (!level->isClientSide && !removed && (xa * xa + ya * ya + za * za) > 0) { remove(); - dropItem(); + dropItem(nullptr); } } @@ -230,7 +231,7 @@ void HangingEntity::push(double xa, double ya, double za) if (!level->isClientSide && !removed && (xa * xa + ya * ya + za * za) > 0) { remove(); - dropItem(); + dropItem(nullptr); } } @@ -289,4 +290,7 @@ void HangingEntity::readAdditionalSaveData(CompoundTag *tag) setDir(dir); } - +bool HangingEntity::repositionEntityAfterLoad() +{ + return false; +}
\ No newline at end of file |
