diff options
Diffstat (limited to 'Minecraft.World/Fireball.cpp')
| -rw-r--r-- | Minecraft.World/Fireball.cpp | 77 |
1 files changed, 27 insertions, 50 deletions
diff --git a/Minecraft.World/Fireball.cpp b/Minecraft.World/Fireball.cpp index 46be68f7..1d9fbdda 100644 --- a/Minecraft.World/Fireball.cpp +++ b/Minecraft.World/Fireball.cpp @@ -63,8 +63,8 @@ Fireball::Fireball(Level *level, double x, double y, double z, double xa, double setSize(16 / 16.0f, 16 / 16.0f); - this->moveTo(x, y, z, yRot, xRot); - this->setPos(x, y, z); + moveTo(x, y, z, yRot, xRot); + setPos(x, y, z); double dd = sqrt(xa * xa + ya * ya + za * za); @@ -84,7 +84,7 @@ Fireball::Fireball(Level *level, double x, double y, double z, double xa, double } } -Fireball::Fireball(Level *level, shared_ptr<Mob> mob, double xa, double ya, double za) : Entity ( level ) +Fireball::Fireball(Level *level, shared_ptr<LivingEntity> mob, double xa, double ya, double za) : Entity ( level ) { // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that // the derived version of the function is called @@ -92,13 +92,13 @@ Fireball::Fireball(Level *level, shared_ptr<Mob> mob, double xa, double ya, doub _init(); - this->owner = mob; + owner = mob; setSize(16 / 16.0f, 16 / 16.0f); - this->moveTo(mob->x, mob->y, mob->z, mob->yRot, mob->xRot); - this->setPos(x, y, z); - this->heightOffset = 0; + moveTo(mob->x, mob->y, mob->z, mob->yRot, mob->xRot); + setPos(x, y, z); + heightOffset = 0; xd = yd = zd = 0.0; @@ -198,7 +198,7 @@ void Fireball::tick() to = Vec3::newTemp(res->pos->x, res->pos->y, res->pos->z); } shared_ptr<Entity> hitEntity = nullptr; - vector<shared_ptr<Entity> > *objects = level->getEntities(shared_from_this(), this->bb->expand(xd, yd, zd)->grow(1, 1, 1)); + vector<shared_ptr<Entity> > *objects = level->getEntities(shared_from_this(), bb->expand(xd, yd, zd)->grow(1, 1, 1)); double nearest = 0; AUTO_VAR(itEnd, objects->end()); for (AUTO_VAR(it, objects->begin()); it != itEnd; it++) @@ -239,8 +239,8 @@ void Fireball::tick() z += zd; double sd = sqrt(xd * xd + zd * zd); - yRot = (float) (atan2(xd, zd) * 180 / PI); - xRot = (float) (atan2(yd, sd) * 180 / PI); + yRot = (float) (atan2(zd, xd) * 180 / PI) + 90; + xRot = (float) (atan2(sd, yd) * 180 / PI) - 90; while (xRot - xRotO < -180) xRotO -= 360; @@ -256,7 +256,7 @@ void Fireball::tick() yRot = yRotO + (yRot - yRotO) * 0.2f; - float inertia = 0.95f; + float inertia = getInertia(); if (isInWater()) { for (int i = 0; i < 4; i++) @@ -292,37 +292,19 @@ void Fireball::tick() setPos(x, y, z); } -void Fireball::onHit(HitResult *res) +float Fireball::getInertia() { - if (!level->isClientSide) - { - if (res->entity != NULL) - { - DamageSource *damageSource = DamageSource::fireball(dynamic_pointer_cast<Fireball>( shared_from_this() ), owner); - if (res->entity->hurt(damageSource, 6)) - { - } - else - { - } - delete damageSource; - } - - bool destroyBlocks = true;//level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); - level->explode(nullptr, x, y, z, 1, true, destroyBlocks); - - remove(); - } + return 0.95f; } void Fireball::addAdditonalSaveData(CompoundTag *tag) { - tag->putShort(L"xTile", (short) xTile); + tag->putShort(L"xTile", (short) xTile); tag->putShort(L"yTile", (short) yTile); tag->putShort(L"zTile", (short) zTile); tag->putByte(L"inTile", (byte) lastTile); tag->putByte(L"inGround", (byte) (inGround ? 1 : 0)); - tag->put(L"direction", this->newDoubleList(3, this->xd, this->yd, this->zd)); + tag->put(L"direction", newDoubleList(3, xd, yd, zd)); } void Fireball::readAdditionalSaveData(CompoundTag *tag) @@ -338,13 +320,13 @@ void Fireball::readAdditionalSaveData(CompoundTag *tag) if (tag->contains(L"direction")) { ListTag<DoubleTag> *listTag = (ListTag<DoubleTag> *)tag->getList(L"direction"); - this->xd = ((DoubleTag *) listTag->get(0))->data; - this->yd = ((DoubleTag *) listTag->get(1))->data; - this->zd = ((DoubleTag *) listTag->get(2))->data; + xd = ((DoubleTag *) listTag->get(0))->data; + yd = ((DoubleTag *) listTag->get(1))->data; + zd = ((DoubleTag *) listTag->get(2))->data; } else { - this->remove(); + remove(); } } @@ -358,8 +340,9 @@ float Fireball::getPickRadius() return 1; } -bool Fireball::hurt(DamageSource *source, int damage) +bool Fireball::hurt(DamageSource *source, float damage) { + if (isInvulnerable()) return false; markHurt(); if (source->getEntity() != NULL) @@ -374,10 +357,9 @@ bool Fireball::hurt(DamageSource *source, int damage) yPower = yd * 0.1; zPower = zd * 0.1; } - shared_ptr<Mob> mob = dynamic_pointer_cast<Mob>( source->getEntity() ); - if (mob != NULL) + if ( source->getEntity()->instanceof(eTYPE_LIVINGENTITY) ) { - owner = mob; + owner = dynamic_pointer_cast<LivingEntity>( source->getEntity() ); } return true; } @@ -399,17 +381,12 @@ int Fireball::getLightColor(float a) return 15 << 20 | 15 << 4; } -bool Fireball::shouldBurn() -{ - return true; -} - -int Fireball::getIcon() +ePARTICLE_TYPE Fireball::getTrailParticleType() { - return 14 + 2 * 16; + return eParticleType_smoke; } -ePARTICLE_TYPE Fireball::getTrailParticleType() +bool Fireball::shouldBurn() { - return eParticleType_smoke; + return true; }
\ No newline at end of file |
