aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/HangingEntity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/HangingEntity.cpp')
-rw-r--r--Minecraft.World/HangingEntity.cpp38
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