Beispiel #1
0
 public void onEntityCollidedWithBlock(World w, BlockPos pos, Entity entity) {
   if (!entity.isSneaking() && Math.abs(entity.motionY) >= 0.25d) {
     entity.motionY += 0.0155 * (entity.fallDistance < 1 ? 1 : entity.fallDistance);
   } else {
     entity.motionY = 0;
   }
   super.onEntityCollidedWithBlock(w, pos, entity);
 }
  @Override
  public void onLanded(World worldIn, Entity entityIn) {
    if (entityIn.isSneaking()) {
      entityIn.motionY = 0;
    } else {
      entityIn.motionY = -entityIn.motionY;

      if (!(entityIn instanceof EntityLivingBase)) {
        entityIn.motionY *= 0.8D;
      } else if (entityIn.motionY < 1 && entityIn.motionY < 1.2) entityIn.motionY *= 1.5;
    }
  }
  @Override
  public void onUpdate() {
    super.onUpdate();
    motionX = motionY = motionZ = 0;
    if (spell == null || ticksExisted > maxTick()) {
      setDead();
      return;
    }

    Entity e = spell.getCaster();
    if (!searched) {
      searched = true;
      targets.addAll(
          worldObj.selectEntitiesWithinAABB(
              EntityLivingBase.class, boundingBox, new ESelectorDefault(spell)));
    }
    if (ticksExisted % interval() == 0) {
      if (!targets.isEmpty()) {
        List<Entity> toRemove = new ArrayList();
        for (Entity ent : targets) {
          if (ent.onGround == false) {
            toRemove.add(ent);
            continue;
          }
          if (ent.getDistanceSq(posX, ent.posY, posZ)
              <= Math.pow(ticksExisted / (double) maxTick() * maxRange(), 2)) {
            spell.damageEntity(ent, 0);
            ent.motionY += spell.countElements() * spell.getPower() * 0.15;
            toRemove.add(ent);
          }
        }
        targets.removeAll(toRemove);
      }
    }
  }
  /** Place an entity in a nearby portal, creating one if necessary. */
  public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) {
    if (this.worldServerInstance.provider.dimensionId != 1) {
      if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) {
        this.makePortal(par1Entity);
        this.placeInExistingPortal(par1Entity, par2, par4, par6, par8);
      }
    } else {
      int i = MathHelper.floor_double(par1Entity.posX);
      int j = MathHelper.floor_double(par1Entity.posY) - 1;
      int k = MathHelper.floor_double(par1Entity.posZ);
      byte b0 = 1;
      byte b1 = 0;

      for (int l = -2; l <= 2; ++l) {
        for (int i1 = -2; i1 <= 2; ++i1) {
          for (int j1 = -1; j1 < 3; ++j1) {
            int k1 = i + i1 * b0 + l * b1;
            int l1 = j + j1;
            int i2 = k + i1 * b1 - l * b0;
            boolean flag = j1 < 0;
            this.worldServerInstance.setBlock(k1, l1, i2, flag ? Blocks.sandstone : Blocks.air);
          }
        }
      }

      par1Entity.setLocationAndAngles(
          (double) i, (double) j, (double) k, par1Entity.rotationYaw, 0.0F);
      par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D;
    }
  }
Beispiel #5
0
  public static void propelTowards(Entity what, Entity whereTo, double force) {
    double dx = whereTo.posX - what.posX;
    double dy = whereTo.posY - what.posY;
    double dz = whereTo.posZ - what.posZ;
    double total = Math.sqrt(dx * dx + dy * dy + dz * dz);

    if (total == 0) {
      what.motionX = 0;
      what.motionY = 0;
      what.motionZ = 0;
    } else {
      what.motionX = dx / total * force;
      what.motionY = dy / total * force;
      what.motionZ = dz / total * force;
    }
  }
Beispiel #6
0
 public void onLanded(World worldIn, Entity entityIn) {
   if (entityIn.isSneaking()) {
     super.onLanded(worldIn, entityIn);
   } else if (entityIn.motionY < 0.0D) {
     entityIn.motionY = -entityIn.motionY;
   }
 }
 @Override
 public void activeAbility(World world, EntityLivingBase user, ItemStack is) {
   consumeMana(world, user, is);
   if (!world.isRemote) {
     ESelectorNonHostile sel = new ESelectorNonHostile();
     ESelectorProjectiles sel1 = new ESelectorProjectiles();
     double range = 16;
     List<Entity> list =
         world.getEntitiesWithinAABB(
             Entity.class,
             AxisAlignedBB.getBoundingBox(
                     user.posX, user.posY, user.posZ, user.posX, user.posY, user.posZ)
                 .expand(range, range, range));
     list.remove(user);
     for (Entity e : list) {
       Vector v = FuncHelper.vectorToEntity(e, user).normalize();
       double power = 0.4 * user.getDistanceToEntity(e);
       if (sel1.isEntityApplicable(e)
           || e instanceof EntityLivingBase
               && sel.isEntityApplicable(e) != sel.isEntityApplicable(user)) {
         v = v.reverse();
         power = 3;
       }
       v = v.multiply(power);
       e.motionX += v.x;
       e.motionY += v.y * 0.5;
       e.motionZ += v.z;
     }
   }
 }
 @Override
 public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
   int meta = world.getBlockMetadata(x, y, z);
   if (meta == 10 || meta == 11) {
     if (entity.motionY < 0) entity.motionY *= -1.2F;
     entity.fallDistance = 0;
   }
 }
  @Override
  public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {

    float shrinkAmount = 1f / 45f;
    if (entity.boundingBox.minY >= y + (1f - shrinkAmount)
        || entity.boundingBox.maxY <= y + shrinkAmount) return;
    entity.fallDistance = 0;
    if (entity.isCollidedHorizontally) {
      entity.motionY = 0.2D;
    } else if (entity.isSneaking()) {
      double diff = entity.prevPosY - entity.posY;
      entity.boundingBox.minY += diff;
      entity.boundingBox.maxY += diff;
      entity.posY = entity.prevPosY;
    } else {
      entity.motionY = -0.12D;
    }
  }
 private void denyEntity(Entity e) {
   e.motionY = 1.5;
   e.fallDistance = Math.max(e.fallDistance, 500);
   e.addVelocity(
       ReikaRandomHelper.getRandomPlusMinus(0, 0.25),
       0,
       ReikaRandomHelper.getRandomPlusMinus(0, 0.25));
   ChromaSounds.POWERDOWN.playSound(e);
 }
Beispiel #11
0
  @Override
  public void applyEntityCollision(Entity e) {
    // TODO elastic collision

    if (e instanceof EntityVehicle) {
      //			(EntityVehicle)e).v.add(vectorB)
    } else {
      e.motionX = 0;
      e.motionY = 0;
      e.motionZ = 0;
    }
  }
  /**
   * Triggered whenever an entity collides with this block (enters into the block). Args: world, x,
   * y, z, entity
   */
  @Override
  public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    if (entity instanceof EntityLivingBase && headInQuicksand(world, x, y, z, entity)) {
      // If the entity is inside of a quicksand block, give some damage. It's only 0.5f damage, so a
      // quarter heart.
      entity.attackEntityFrom(DamageSourceQuicksand.instance, 0.5f);

      // I tried to make it render the texture on your screen like if you're in a block,
      // but it turned out to be a private method.
    }
    if (insideQuicksand(world, x, y, z, entity)) {
      // If the entity inside of the quicksand is a player, make the player fall slowly.
      // If the player is moving horizontally ("struggling"), make them fall faster.
      // If the player is sneaking, make them "swim" upwards.
      if (entity instanceof EntityPlayer) {
        double horizMotion =
            Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ);
        if (horizMotion > 0.0) {
          if (debug) System.out.println("Horizonal Motion: " + horizMotion);
        }
        if (entity.isSneaking()) {
          // Make the player go up slowly. Weird numbers, right?
          entity.motionY = 0.085102044;
        } else {
          // Make the player go down slowly. Seriously, I don't know why these numbers are so exact.
          entity.motionY = 0.074897955;
        }
        if (horizMotion > 0.001) {
          // If the player is moving significantly horizontally, make them sink faster.
          entity.motionY -= horizMotion * 0.3;
        }
        entity.fallDistance = 0;
      } else {
        // If not a player, just set the entity in a web.
        // It's a bit glitchy otherwise... especially with chickens, who don't sink.
        entity.setInWeb();
      }
    }
  }
Beispiel #13
0
  public boolean attackEntityAsMob(Entity entityIn) {
    this.attackTimer = 10;
    this.worldObj.setEntityState(this, (byte) 4);
    boolean flag =
        entityIn.attackEntityFrom(
            DamageSource.causeMobDamage(this), (float) (7 + this.rand.nextInt(15)));

    if (flag) {
      entityIn.motionY += 0.4000000059604645D;
      this.applyEnchantments(this, entityIn);
    }

    this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
    return flag;
  }
 private void modifyEntity(Entity e) {
   double dx = e.posX - xCoord - 0.5;
   double dy = e.posY - yCoord - 0.5;
   double dz = e.posZ - zCoord - 0.5;
   if (ReikaMathLibrary.py3d(dx, 0, dz) <= this.getRange()) {
     double dd = ReikaMathLibrary.py3d(dx, dy, dz);
     double v = 2;
     e.motionX *= 0.5;
     e.motionZ *= 0.5;
     e.motionX += -dx * v / dd;
     e.motionY += 0.25 - dy * v / dd;
     e.motionZ += -dz * v / dd;
     if (!e.worldObj.isRemote) e.velocityChanged = true;
   }
 }
Beispiel #15
0
  private void func_145863_a(float p_145863_1_, float p_145863_2_) {
    if (this.extending) {
      p_145863_1_ = 1.0F - p_145863_1_;
    } else {
      --p_145863_1_;
    }

    AxisAlignedBB var3 =
        Blocks.piston_extension.func_176424_a(
            this.worldObj, this.pos, this.field_174932_a, p_145863_1_, this.field_174931_f);

    if (var3 != null) {
      List var4 = this.worldObj.getEntitiesWithinAABBExcludingEntity((Entity) null, var3);

      if (!var4.isEmpty()) {
        this.field_174933_k.addAll(var4);
        Iterator var5 = this.field_174933_k.iterator();

        while (var5.hasNext()) {
          Entity var6 = (Entity) var5.next();

          if (this.field_174932_a.getBlock() == Blocks.slime_block && this.extending) {
            switch (TileEntityPiston.SwitchAxis.field_177248_a[
                this.field_174931_f.getAxis().ordinal()]) {
              case 1:
                var6.motionX = (double) this.field_174931_f.getFrontOffsetX();
                break;

              case 2:
                var6.motionY = (double) this.field_174931_f.getFrontOffsetY();
                break;

              case 3:
                var6.motionZ = (double) this.field_174931_f.getFrontOffsetZ();
            }
          } else {
            var6.moveEntity(
                (double) (p_145863_2_ * (float) this.field_174931_f.getFrontOffsetX()),
                (double) (p_145863_2_ * (float) this.field_174931_f.getFrontOffsetY()),
                (double) (p_145863_2_ * (float) this.field_174931_f.getFrontOffsetZ()));
          }
        }

        this.field_174933_k.clear();
      }
    }
  }
 @Override
 public void passiveAbility(World world, EntityLivingBase user, ItemStack is) {
   if (user.ticksExisted % 4 == 0) {
     double range = 8;
     List<Entity> list =
         world.selectEntitiesWithinAABB(
             Entity.class,
             AxisAlignedBB.getBoundingBox(
                     user.posX, user.posY, user.posZ, user.posX, user.posY, user.posZ)
                 .expand(range, range, range),
             new ESelectorProjectiles());
     for (Entity e : list) {
       Vector v = FuncHelper.vectorToEntity(user, e).normalize();
       e.motionX += v.x * 0.35;
       e.motionY += v.y * 0.35;
       e.motionZ += v.z * 0.35;
     }
   }
 }
Beispiel #17
0
 public void setVelocity(Vector vel) {
   entity.motionX = vel.getX();
   entity.motionY = vel.getY();
   entity.motionZ = vel.getZ();
   entity.velocityChanged = true;
 }
Beispiel #18
0
  @Override
  public void doExplode() {
    int r = callCount;

    if (!worldObj.isRemote) {
      if (thread != null && thread.isComplete) {
        Iterator<Pos3D> it = thread.results.iterator();

        while (it.hasNext()) {
          Pos3D targetPosition = it.next();
          double distance = targetPosition.clone().distance(position);

          if (distance > r || distance < r - 3) continue;

          Block block =
              this.worldObj.getBlock(
                  (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos);

          if (!DefenseUtils.canBreak(
              worldObj, block, targetPosition.xPos, targetPosition.yPos, targetPosition.zPos)) {
            continue;
          }

          if (worldObj.isAirBlock(
                  (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos)
              || block == Blocks.bedrock
              || block == Blocks.obsidian) {
            continue;
          }

          int metadata =
              this.worldObj.getBlockMetadata(
                  (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos);

          if (distance < r - 1 || this.worldObj.rand.nextInt(3) > 0) {
            if (block == DefenseTechBlocks.blockExplosive) {
              BlockExplosive.detonate(
                  this.worldObj,
                  (int) targetPosition.xPos,
                  (int) targetPosition.yPos,
                  (int) targetPosition.zPos,
                  ((TileExplosive)
                          this.worldObj.getTileEntity(
                              (int) targetPosition.xPos,
                              (int) targetPosition.yPos,
                              (int) targetPosition.zPos))
                      .explosiveID,
                  1);
            } else {
              this.worldObj.setBlockToAir(
                  (int) targetPosition.xPos, (int) targetPosition.yPos, (int) targetPosition.zPos);
            }

            targetPosition.translate(0.5D, 0.5D, 0.5D);

            if (this.worldObj.rand.nextFloat() < 0.3 * (this.getRadius() - r)) {
              EntityFlyingBlock entity =
                  new EntityFlyingBlock(this.worldObj, targetPosition, block, metadata);
              this.worldObj.spawnEntityInWorld(entity);
              entity.yawChange = 50 * this.worldObj.rand.nextFloat();
              entity.pitchChange = 100 * this.worldObj.rand.nextFloat();
            }

            it.remove();
          }
        }
      }
    }

    int radius = 2 * this.callCount;
    AxisAlignedBB bounds =
        AxisAlignedBB.getBoundingBox(
            position.xPos - radius,
            position.yPos - radius,
            position.zPos - radius,
            position.xPos + radius,
            position.yPos + radius,
            position.zPos + radius);
    List<Entity> allEntities = this.worldObj.getEntitiesWithinAABB(Entity.class, bounds);

    synchronized (allEntities) {
      for (Iterator it = allEntities.iterator(); it.hasNext(); ) {
        Entity entity = (Entity) it.next();

        if (entity instanceof EntityMissile) {
          ((EntityMissile) entity).setExplode();
          break;
        } else {
          double xDifference = entity.posX - position.xPos;
          double zDifference = entity.posZ - position.zPos;

          r = (int) this.getRadius();
          if (xDifference < 0) r = (int) -this.getRadius();

          entity.motionX += (r - xDifference) * 0.02 * this.worldObj.rand.nextFloat();
          entity.motionY += 3 * this.worldObj.rand.nextFloat();

          r = (int) this.getRadius();
          if (zDifference < 0) r = (int) -this.getRadius();

          entity.motionZ += (r - zDifference) * 0.02 * this.worldObj.rand.nextFloat();
        }
      }
    }

    if (this.callCount > this.getRadius()) {
      this.controller.endExplosion();
    }
  }
  /** Does the first part of the explosion (destroy blocks) */
  @Override
  public void doExplosionA() {
    float var1 = explosionSize;
    int var3;
    int var4;
    int var5;
    double var15;
    double var17;
    double var19;

    for (var3 = 0; var3 < field_77289_h; ++var3) {
      for (var4 = 0; var4 < field_77289_h; ++var4) {
        for (var5 = 0; var5 < field_77289_h; ++var5) {
          if (var3 == 0
              || var3 == field_77289_h - 1
              || var4 == 0
              || var4 == field_77289_h - 1
              || var5 == 0
              || var5 == field_77289_h - 1) {
            double var6 = var3 / (field_77289_h - 1.0F) * 2.0F - 1.0F;
            double var8 = var4 / (field_77289_h - 1.0F) * 2.0F - 1.0F;
            double var10 = var5 / (field_77289_h - 1.0F) * 2.0F - 1.0F;
            double var12 = Math.sqrt(var6 * var6 + var8 * var8 + var10 * var10);
            var6 /= var12;
            var8 /= var12;
            var10 /= var12;
            var15 = explosionX;
            var17 = explosionY;
            var19 = explosionZ;
          }
        }
      }
    }

    explosionSize *= 2.0F;
    var3 = MathHelper.floor_double(explosionX - explosionSize - 1.0D);
    var4 = MathHelper.floor_double(explosionX + explosionSize + 1.0D);
    var5 = MathHelper.floor_double(explosionY - explosionSize - 1.0D);
    int var28 = MathHelper.floor_double(explosionY + explosionSize + 1.0D);
    int var7 = MathHelper.floor_double(explosionZ - explosionSize - 1.0D);
    int var29 = MathHelper.floor_double(explosionZ + explosionSize + 1.0D);
    List var9 =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            exploder, AxisAlignedBB.getBoundingBox(var3, var5, var7, var4, var28, var29));

    Vec3 var30 = Vec3.createVectorHelper(explosionX, explosionY, explosionZ);

    for (int var11 = 0; var11 < var9.size(); ++var11) {
      Entity var31 = (Entity) var9.get(var11);
      if (!(var31 instanceof EntityLiving)) {
        continue;
      }
      if (var31 == shootingEntity && !hurtsPlayer) {
        continue;
      }
      double var13 = var31.getDistance(explosionX, explosionY, explosionZ) / explosionSize;
      if (var13 <= 1.0D) {
        var15 = var31.posX - explosionX;
        var17 = var31.posY + var31.getEyeHeight() - explosionY;
        var19 = var31.posZ - explosionZ;
        double var33 = MathHelper.sqrt_double(var15 * var15 + var17 * var17 + var19 * var19);

        if (var33 != 0.0D) {
          var15 /= var33;
          var17 /= var33;
          var19 /= var33;
          double var32 = worldObj.getBlockDensity(var30, var31.boundingBox);
          double var34 = (1.0D - var13) * var32;
          var31.attackEntityFrom(
              DamageSource.causePlayerDamage(shootingEntity),
              (int) ((var34 * var34 + var34) * 6.0D * (explosionSize * 2) + 3.0D));
          var31.motionX += var15 * var34;
          var31.motionY += var17 * var34;
          var31.motionZ += var19 * var34;

          if (var31 instanceof EntityPlayer) {
            field_77288_k.put(
                var31, Vec3.createVectorHelper(var15 * var34, var17 * var34, var19 * var34));
          }
        }
      }
    }

    explosionSize = var1;
  }
  @Override
  public void updateWeather() {
    super.updateWeather();

    if (!this.worldObj.isRemote) {
      if (this.dataNotLoaded) {
        this.savefile = OrbitSpinSaveData.initWorldData(this.worldObj);
        this.readFromNBT(this.savefile.datacompound);
        if (ConfigManagerCore.enableDebug)
          System.out.println(
              "Loading data from save: " + this.savefile.datacompound.getFloat("omegaSky"));
        this.dataNotLoaded = false;
      }

      if (this.doSpinning) {
        boolean updateNeeded = true;
        if (this.angularVelocityTarget < this.angularVelocityRadians) {
          float newAngle = this.angularVelocityRadians - this.angularVelocityAccel;
          if (newAngle < this.angularVelocityTarget) {
            newAngle = this.angularVelocityTarget;
          }
          this.setSpinRate(newAngle);
          this.thrustersFiring = true;
        } else if (this.angularVelocityTarget > this.angularVelocityRadians) {
          float newAngle = this.angularVelocityRadians + this.angularVelocityAccel;
          if (newAngle > this.angularVelocityTarget) {
            newAngle = this.angularVelocityTarget;
          }
          this.setSpinRate(newAngle);
          this.thrustersFiring = true;
        } else if (this.thrustersFiring) {
          this.thrustersFiring = false;
        } else {
          updateNeeded = false;
        }

        if (updateNeeded) {
          this.writeToNBT(this.savefile.datacompound);
          this.savefile.markDirty();

          List<Object> objList = new ArrayList<Object>();
          objList.add(Float.valueOf(this.angularVelocityRadians));
          objList.add(Boolean.valueOf(this.thrustersFiring));
          GalacticraftCore.packetPipeline.sendToDimension(
              new PacketSimple(EnumSimplePacket.C_UPDATE_STATION_SPIN, objList),
              this.spaceStationDimensionID);
        }

        // Update entity positions if in freefall
        this.loadedEntities.clear();
        this.loadedEntities.addAll(this.worldObj.loadedEntityList);
        for (Entity e : this.loadedEntities) {
          if ((e instanceof EntityItem
                  || e instanceof EntityLivingBase && !(e instanceof EntityPlayer)
                  || e instanceof EntityTNTPrimed
                  || e instanceof EntityFallingBlock)
              && !e.onGround) {
            boolean freefall = true;
            if (e.boundingBox.maxX >= this.ssBoundsMinX
                && e.boundingBox.minX <= this.ssBoundsMaxX
                && e.boundingBox.maxY >= this.ssBoundsMinY
                && e.boundingBox.minY <= this.ssBoundsMaxY
                && e.boundingBox.maxZ >= this.ssBoundsMinZ
                && e.boundingBox.minZ <= this.ssBoundsMaxZ) {
              // Entity is somewhere within the space station boundaries

              // Check if the entity's bounding box is in the same block coordinates as any
              // non-vacuum block (including torches etc)
              // If so, it's assumed the entity has something close enough to catch onto, so is not
              // in freefall
              // Note: breatheable air here means the entity is definitely not in freefall
              int xmx = MathHelper.floor_double(e.boundingBox.maxX + 0.2D);
              int ym = MathHelper.floor_double(e.boundingBox.minY - 0.1D);
              int yy = MathHelper.floor_double(e.boundingBox.maxY + 0.1D);
              int zm = MathHelper.floor_double(e.boundingBox.minZ - 0.2D);
              int zz = MathHelper.floor_double(e.boundingBox.maxZ + 0.2D);
              BLOCKCHECK:
              for (int x = MathHelper.floor_double(e.boundingBox.minX - 0.2D); x <= xmx; x++) {
                for (int y = ym; y <= yy; y++) {
                  for (int z = zm; z <= zz; z++) {
                    if (this.worldObj.blockExists(x, y, z)
                        && this.worldObj.getBlock(x, y, z) != Blocks.air) {
                      freefall = false;
                      break BLOCKCHECK;
                    }
                  }
                }
              }
            }

            if (freefall) {
              // Do the rotation
              if (this.angularVelocityRadians != 0F) {
                float angle;
                final double xx = e.posX - this.spinCentreX;
                final double zz = e.posZ - this.spinCentreZ;
                double arc = Math.sqrt(xx * xx + zz * zz);
                if (xx == 0D) {
                  angle = zz > 0 ? 3.141592536F / 2 : -3.141592536F / 2;
                } else {
                  angle = (float) Math.atan(zz / xx);
                }
                if (xx < 0D) {
                  angle += 3.141592536F;
                }
                angle += this.angularVelocityRadians / 3F;
                arc = arc * this.angularVelocityRadians;
                final double offsetX = -arc * MathHelper.sin(angle);
                final double offsetZ = arc * MathHelper.cos(angle);
                e.posX += offsetX;
                e.posZ += offsetZ;
                e.lastTickPosX += offsetX;
                e.lastTickPosZ += offsetZ;

                // Rotated into an unloaded chunk (probably also drifted out to there): byebye
                if (!this.worldObj.blockExists(
                    MathHelper.floor_double(e.posX), 64, MathHelper.floor_double(e.posZ))) {
                  e.setDead();
                }

                e.boundingBox.offset(offsetX, 0.0D, offsetZ);
                // TODO check for block collisions here - if so move the entity appropriately and
                // apply fall damage
                // Moving the entity = slide along / down
                e.rotationYaw += this.skyAngularVelocity;
                while (e.rotationYaw > 360F) {
                  e.rotationYaw -= 360F;
                }
              }

              // Undo deceleration
              if (e instanceof EntityLivingBase) {
                e.motionX /= 0.91F;
                e.motionZ /= 0.91F;
                if (e instanceof EntityFlying) {
                  e.motionY /= 0.91F;
                } else if (e instanceof EntityFallingBlock) {
                  e.motionY /= 0.9800000190734863D;
                  // e.motionY += 0.03999999910593033D;
                  // e.posY += 0.03999999910593033D;
                  // e.lastTickPosY += 0.03999999910593033D;
                } else {
                  e.motionY /= 0.9800000190734863D;
                }
              } else {
                e.motionX /= 0.9800000190734863D;
                e.motionY /= 0.9800000190734863D;
                e.motionZ /= 0.9800000190734863D;
              }
            }
          }
        }
      }
    }
  }
Beispiel #21
0
 public void onEntityWalking(World world, int x, int y, int z, Entity entity) {
   entity.motionY += 2.0;
 }
 private static void setVelocity(Entity entity, Vector3 v) {
   entity.motionX = v.x;
   entity.motionY = v.y;
   entity.motionZ = v.z;
 }
Beispiel #23
0
  /** Does the first part of the explosion (destroy blocks) */
  public void doExplosionA() {
    HashSet var1 = Sets.newHashSet();
    boolean var2 = true;
    int var4;
    int var5;

    for (int var3 = 0; var3 < 16; ++var3) {
      for (var4 = 0; var4 < 16; ++var4) {
        for (var5 = 0; var5 < 16; ++var5) {
          if (var3 == 0 || var3 == 15 || var4 == 0 || var4 == 15 || var5 == 0 || var5 == 15) {
            double var6 = (double) ((float) var3 / 15.0F * 2.0F - 1.0F);
            double var8 = (double) ((float) var4 / 15.0F * 2.0F - 1.0F);
            double var10 = (double) ((float) var5 / 15.0F * 2.0F - 1.0F);
            double var12 = Math.sqrt(var6 * var6 + var8 * var8 + var10 * var10);
            var6 /= var12;
            var8 /= var12;
            var10 /= var12;
            float var14 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F);
            double var15 = this.explosionX;
            double var17 = this.explosionY;
            double var19 = this.explosionZ;

            for (float var21 = 0.3F; var14 > 0.0F; var14 -= 0.22500001F) {
              BlockPos var22 = new BlockPos(var15, var17, var19);
              IBlockState var23 = this.worldObj.getBlockState(var22);

              if (var23.getBlock().getMaterial() != Material.air) {
                float var24 =
                    this.exploder != null
                        ? this.exploder.getExplosionResistance(this, this.worldObj, var22, var23)
                        : var23.getBlock().getExplosionResistance((Entity) null);
                var14 -= (var24 + 0.3F) * 0.3F;
              }

              if (var14 > 0.0F
                  && (this.exploder == null
                      || this.exploder.func_174816_a(this, this.worldObj, var22, var23, var14))) {
                var1.add(var22);
              }

              var15 += var6 * 0.30000001192092896D;
              var17 += var8 * 0.30000001192092896D;
              var19 += var10 * 0.30000001192092896D;
            }
          }
        }
      }
    }

    this.affectedBlockPositions.addAll(var1);
    float var30 = this.explosionSize * 2.0F;
    var4 = MathHelper.floor_double(this.explosionX - (double) var30 - 1.0D);
    var5 = MathHelper.floor_double(this.explosionX + (double) var30 + 1.0D);
    int var31 = MathHelper.floor_double(this.explosionY - (double) var30 - 1.0D);
    int var7 = MathHelper.floor_double(this.explosionY + (double) var30 + 1.0D);
    int var32 = MathHelper.floor_double(this.explosionZ - (double) var30 - 1.0D);
    int var9 = MathHelper.floor_double(this.explosionZ + (double) var30 + 1.0D);
    List var33 =
        this.worldObj.getEntitiesWithinAABBExcludingEntity(
            this.exploder,
            new AxisAlignedBB(
                (double) var4,
                (double) var31,
                (double) var32,
                (double) var5,
                (double) var7,
                (double) var9));
    Vec3 var11 = new Vec3(this.explosionX, this.explosionY, this.explosionZ);

    for (int var34 = 0; var34 < var33.size(); ++var34) {
      Entity var13 = (Entity) var33.get(var34);

      if (!var13.func_180427_aV()) {
        double var35 =
            var13.getDistance(this.explosionX, this.explosionY, this.explosionZ) / (double) var30;

        if (var35 <= 1.0D) {
          double var16 = var13.posX - this.explosionX;
          double var18 = var13.posY + (double) var13.getEyeHeight() - this.explosionY;
          double var20 = var13.posZ - this.explosionZ;
          double var36 =
              (double) MathHelper.sqrt_double(var16 * var16 + var18 * var18 + var20 * var20);

          if (var36 != 0.0D) {
            var16 /= var36;
            var18 /= var36;
            var20 /= var36;
            double var37 =
                (double) this.worldObj.getBlockDensity(var11, var13.getEntityBoundingBox());
            double var26 = (1.0D - var35) * var37;
            var13.attackEntityFrom(
                DamageSource.setExplosionSource(this),
                (float) ((int) ((var26 * var26 + var26) / 2.0D * 8.0D * (double) var30 + 1.0D)));
            double var28 = EnchantmentProtection.func_92092_a(var13, var26);
            var13.motionX += var16 * var28;
            var13.motionY += var18 * var28;
            var13.motionZ += var20 * var28;

            if (var13 instanceof EntityPlayer) {
              this.field_77288_k.put(
                  (EntityPlayer) var13, new Vec3(var16 * var26, var18 * var26, var20 * var26));
            }
          }
        }
      }
    }
  }
  @SuppressWarnings({"rawtypes", "unchecked"})
  public void doExplosionA() {
    float f = this.explosionSize;
    int i;
    int j;
    int k;
    double d0;
    double d1;
    double d2;

    for (i = 0; i < this.field_77289_h; ++i) {
      for (j = 0; j < this.field_77289_h; ++j) {
        for (k = 0; k < this.field_77289_h; ++k) {
          if (i == 0
              || i == this.field_77289_h - 1
              || j == 0
              || j == this.field_77289_h - 1
              || k == 0
              || k == this.field_77289_h - 1) {
            double d3 = i / (this.field_77289_h - 1.0F) * 2.0F - 1.0F;
            double d4 = j / (this.field_77289_h - 1.0F) * 2.0F - 1.0F;
            double d5 = k / (this.field_77289_h - 1.0F) * 2.0F - 1.0F;
            double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
            d3 /= d6;
            d4 /= d6;
            d5 /= d6;
            float f1 = this.explosionSize * (0.7F + this.worldObj.rand.nextFloat() * 0.6F);
            d0 = this.explosionX;
            d1 = this.explosionY;
            d2 = this.explosionZ;

            for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) {
              d0 += d3 * f2;
              d1 += d4 * f2;
              d2 += d5 * f2;
            }
          }
        }
      }
    }

    this.explosionSize *= 2.0F;
    i = MathHelper.floor_double(this.explosionX - this.explosionSize - 1.0D);
    j = MathHelper.floor_double(this.explosionX + this.explosionSize + 1.0D);
    k = MathHelper.floor_double(this.explosionY - this.explosionSize - 1.0D);
    int l1 = MathHelper.floor_double(this.explosionY + this.explosionSize + 1.0D);
    int i2 = MathHelper.floor_double(this.explosionZ - this.explosionSize - 1.0D);
    int j2 = MathHelper.floor_double(this.explosionZ + this.explosionSize + 1.0D);
    List list =
        this.worldObj.getEntitiesWithinAABBExcludingEntity(
            this.exploder, AxisAlignedBB.getBoundingBox(i, k, i2, j, l1, j2));
    Vec3 vec3 = Vec3.createVectorHelper(this.explosionX, this.explosionY, this.explosionZ);

    for (int k2 = 0; k2 < list.size(); ++k2) {
      Entity entity = (Entity) list.get(k2);
      double d7 =
          entity.getDistance(this.explosionX, this.explosionY, this.explosionZ)
              / this.explosionSize;

      if (d7 <= 1.0D) {
        d0 = entity.posX - this.explosionX;
        d1 = entity.posY + entity.getEyeHeight() - this.explosionY;
        d2 = entity.posZ - this.explosionZ;
        double d8 = MathHelper.sqrt_double(d0 * d0 + d1 * d1 + d2 * d2);

        if (d8 != 0.0D) {
          d0 /= d8;
          d1 /= d8;
          d2 /= d8;
          double d9 = this.worldObj.getBlockDensity(vec3, entity.boundingBox);
          double d10 = (1.0D - d7) * d9;
          double d11 = EnchantmentProtection.func_92092_a(entity, d10);
          entity.attackEntityFrom(DamageSource.generic, 0.0001F);
          entity.motionX += (d0 * d11);
          entity.motionY += (d1 * d11) * explosionPower;
          entity.motionZ += (d2 * d11);

          if (entity instanceof EntityPlayer)
            this.field_77288_k.put(entity, Vec3.createVectorHelper(d0 * d10, d1 * d10, d2 * d10));
        }
      }
    }

    this.explosionSize = f;
  }
  /** Place an entity in a nearby portal which already exists. */
  @SuppressWarnings("unchecked")
  public boolean placeInExistingPortal(
      Entity par1Entity, double par2, double par4, double par6, float par8) {
    short short1 = 128;
    double d3 = -1.0D;
    int i = 0;
    int j = 0;
    int k = 0;
    int l = MathHelper.floor_double(par1Entity.posX);
    int i1 = MathHelper.floor_double(par1Entity.posZ);
    long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1);
    boolean flag = true;
    double d4;
    int k1;

    if (this.field_85191_c.containsItem(j1)) {
      PortalPosition portalposition = (PortalPosition) this.field_85191_c.getValueByKey(j1);
      d3 = 0.0D;
      i = portalposition.posX;
      j = portalposition.posY;
      k = portalposition.posZ;
      portalposition.lastUpdateTime = this.worldServerInstance.getTotalWorldTime();
      flag = false;
    } else {
      for (k1 = l - short1; k1 <= l + short1; ++k1) {
        double d5 = (double) k1 + 0.5D - par1Entity.posX;

        for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) {
          double d6 = (double) l1 + 0.5D - par1Entity.posZ;

          for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) {
            if (this.worldServerInstance.getBlock(k1, i2, l1) == DimBlocks.BlockDebug) {
              while (this.worldServerInstance.getBlock(k1, i2 - 1, l1) == DimBlocks.BlockDebug) {
                --i2;
              }

              d4 = (double) i2 + 0.5D - par1Entity.posY;
              double d7 = d5 * d5 + d4 * d4 + d6 * d6;

              if (d3 < 0.0D || d7 < d3) {
                d3 = d7;
                i = k1;
                j = i2;
                k = l1;
              }
            }
          }
        }
      }
    }

    if (d3 >= 0.0D) {
      if (flag) {
        // TODO ERROR?
        this.field_85191_c.add(
            j1, new PortalPosition(i, j, k, this.worldServerInstance.getTotalWorldTime()));
        this.field_85190_d.add(Long.valueOf(j1));
      }

      double d8 = (double) i + 0.5D;
      double d9 = (double) j + 0.5D;
      d4 = (double) k + 0.5D;
      int j2 = -1;

      if (this.worldServerInstance.getBlock(i - 1, j, k) == DimBlocks.BlockDebug) {
        j2 = 2;
      }

      if (this.worldServerInstance.getBlock(i + 1, j, k) == DimBlocks.BlockDebug) {
        j2 = 0;
      }

      if (this.worldServerInstance.getBlock(i, j, k - 1) == DimBlocks.BlockDebug) {
        j2 = 3;
      }

      if (this.worldServerInstance.getBlock(i, j, k + 1) == DimBlocks.BlockDebug) {
        j2 = 1;
      }

      int k2 = par1Entity.getTeleportDirection();

      if (j2 > -1) {
        int l2 = Direction.rotateLeft[j2];
        int i3 = Direction.offsetX[j2];
        int j3 = Direction.offsetZ[j2];
        int k3 = Direction.offsetX[l2];
        int l3 = Direction.offsetZ[l2];
        boolean flag1 =
            !this.worldServerInstance.isAirBlock(i + i3 + k3, j, k + j3 + l3)
                || !this.worldServerInstance.isAirBlock(i + i3 + k3, j + 1, k + j3 + l3);
        boolean flag2 =
            !this.worldServerInstance.isAirBlock(i + i3, j, k + j3)
                || !this.worldServerInstance.isAirBlock(i + i3, j + 1, k + j3);

        if (flag1 && flag2) {
          j2 = Direction.rotateOpposite[j2];
          l2 = Direction.rotateOpposite[l2];
          i3 = Direction.offsetX[j2];
          j3 = Direction.offsetZ[j2];
          k3 = Direction.offsetX[l2];
          l3 = Direction.offsetZ[l2];
          k1 = i - k3;
          d8 -= (double) k3;
          int i4 = k - l3;
          d4 -= (double) l3;
          flag1 =
              !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j, i4 + j3 + l3)
                  || !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j + 1, i4 + j3 + l3);
          flag2 =
              !this.worldServerInstance.isAirBlock(k1 + i3, j, i4 + j3)
                  || !this.worldServerInstance.isAirBlock(k1 + i3, j + 1, i4 + j3);
        }

        float f1 = 0.5F;
        float f2 = 0.5F;

        if (!flag1 && flag2) {
          f1 = 1.0F;
        } else if (flag1 && !flag2) {
          f1 = 0.0F;
        } else if (flag1 && flag2) {
          f2 = 0.0F;
        }

        d8 += (double) ((float) k3 * f1 + f2 * (float) i3);
        d4 += (double) ((float) l3 * f1 + f2 * (float) j3);
        float f3 = 0.0F;
        float f4 = 0.0F;
        float f5 = 0.0F;
        float f6 = 0.0F;

        if (j2 == k2) {
          f3 = 1.0F;
          f4 = 1.0F;
        } else if (j2 == Direction.rotateOpposite[k2]) {
          f3 = -1.0F;
          f4 = -1.0F;
        } else if (j2 == Direction.rotateRight[k2]) {
          f5 = 1.0F;
          f6 = -1.0F;
        } else {
          f5 = -1.0F;
          f6 = 1.0F;
        }

        double d10 = par1Entity.motionX;
        double d11 = par1Entity.motionZ;
        par1Entity.motionX = d10 * (double) f3 + d11 * (double) f6;
        par1Entity.motionZ = d10 * (double) f5 + d11 * (double) f4;
        par1Entity.rotationYaw = par8 - (float) (k2 * 90) + (float) (j2 * 90);
      } else {
        par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D;
      }

      par1Entity.setLocationAndAngles(d8, d9, d4, par1Entity.rotationYaw, par1Entity.rotationPitch);
      return true;
    } else {
      return false;
    }
  }
  @Override
  public void doExplode() {
    int r = this.callCount;

    if (!this.world().isRemote && this.thread.isComplete) {
      int blocksToTake = 20;

      for (Vector3 targetPosition : this.thread.results) {
        double distance = targetPosition.add(position).magnitude();

        if (distance > r || distance < r - 2 || blocksToTake <= 0) continue;

        Block block =
            world().getBlock(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());

        if (block == null
            || block.getBlockHardness(
                    world(), targetPosition.xi(), targetPosition.yi(), targetPosition.zi())
                < 0) continue;

        // if (block instanceof IForceFieldBlock)
        //    continue;

        int metadata =
            world().getBlockMetadata(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());

        if (distance < r - 1 || world().rand.nextInt(3) > 0) {
          this.world().setBlockToAir(targetPosition.xi(), targetPosition.yi(), targetPosition.zi());

          targetPosition.add(0.5D);

          if (world().rand.nextFloat() < 0.3 * (this.getRadius() - r)) {
            EntityFlyingBlock entity =
                new EntityFlyingBlock(world(), targetPosition, block, metadata, 0);
            world().spawnEntityInWorld(entity);
            flyingBlocks.add(entity);
            entity.yawChange = 50 * world().rand.nextFloat();
            entity.pitchChange = 100 * world().rand.nextFloat();
            entity.motionY += Math.max(0.15 * world().rand.nextFloat(), 0.1);
          }

          blocksToTake--;
        }
      }
    }

    int radius = (int) this.getRadius();
    AxisAlignedBB bounds =
        AxisAlignedBB.getBoundingBox(
            position.xi() - radius,
            position.yi() - radius,
            position.zi() - radius,
            position.xi() + radius,
            100,
            position.zi() + radius);
    List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, bounds);

    for (Entity entity : allEntities) {
      if (!(entity instanceof EntityFlyingBlock) && entity.posY < 100 + position.yi()) {
        if (entity.motionY < 0.4) {
          entity.motionY += 0.15;
        }
      }
    }

    if (this.callCount > 20 * 120) {
      this.controller.endExplosion();
    }
  }
  /**
   * @author gabizou - April 8th, 2016
   * @reason Rewrites the attackTargetEntityWithCurrentItem to throw an {@link AttackEntityEvent}
   *     prior to the ensuing {@link DamageEntityEvent}. This should cover all cases where players
   *     are attacking entities and those entities override {@link
   *     EntityLivingBase#attackEntityFrom(DamageSource, float)} and effectively bypass our damage
   *     event hooks.
   * @param targetEntity The target entity
   */
  @Overwrite
  public void attackTargetEntityWithCurrentItem(net.minecraft.entity.Entity targetEntity) {
    // Sponge Start - Add SpongeImpl hook to override in forge as necessary
    if (!SpongeImplHooks.checkAttackEntity((EntityPlayer) (Object) this, targetEntity)) {
      return;
    }
    // Sponge End
    if (targetEntity.canAttackWithItem()) {
      if (!targetEntity.hitByEntity((EntityPlayer) (Object) this)) {
        // Sponge Start - Prepare our event values
        // float baseDamage =
        // this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
        final double originalBaseDamage =
            this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
        float baseDamage = (float) originalBaseDamage;
        // Sponge End
        int knockbackModifier = 0;
        float enchantmentModifierAmount = 0.0F;

        // Sponge Start - gather the attack modifiers
        final List<Tuple<DamageModifier, Function<? super Double, Double>>> originalFunctions =
            new ArrayList<>();

        final EnumCreatureAttribute creatureAttribute =
            targetEntity instanceof EntityLivingBase
                ? ((EntityLivingBase) targetEntity).getCreatureAttribute()
                : EnumCreatureAttribute.UNDEFINED;
        final List<Tuple<DamageModifier, Function<? super Double, Double>>>
            enchantmentModifierFunctions =
                DamageEventHandler.createAttackEnchamntmentFunction(
                    this.getHeldItem(), creatureAttribute);
        // if (targetEntity instanceof EntityLivingBase) {
        //     enchantmentModifierAmount =
        // EnchantmentHelper.getModifierForCreature(this.getHeldItem(), creatureAttribute);
        // } else {
        //     enchantmentModifierAmount =
        // EnchantmentHelper.getModifierForCreature(this.getHeldItem(),
        // EnumCreatureAttribute.UNDEFINED);
        // }
        enchantmentModifierAmount =
            (float)
                enchantmentModifierFunctions
                    .stream()
                    .map(Tuple::getSecond)
                    .mapToDouble(function -> function.apply(originalBaseDamage))
                    .sum();
        originalFunctions.addAll(enchantmentModifierFunctions);
        // Sponge End

        knockbackModifier =
            knockbackModifier
                + EnchantmentHelper.getKnockbackModifier((EntityPlayer) (Object) this);

        if (this.isSprinting()) {
          ++knockbackModifier;
        }

        if (baseDamage > 0.0F || enchantmentModifierAmount > 0.0F) {
          boolean fallingCriticalHit =
              this.fallDistance > 0.0F
                  && !this.onGround
                  && !this.isOnLadder()
                  && !this.isInWater()
                  && !this.isPotionActive(Potion.blindness)
                  && this.ridingEntity == null
                  && targetEntity instanceof EntityLivingBase;

          if (fallingCriticalHit && baseDamage > 0.0F) {
            // Sponge - Add the function for critical attacking
            originalFunctions.add(
                DamageEventHandler.provideCriticalAttackTuple((EntityPlayer) (Object) this));
            // baseDamage *= 1.5F; Sponge - remove since it's handled in the event
          }

          // baseDamage = baseDamage + enchantmentModifierAmount; // Sponge - remove since it is
          // delegated through the event.
          boolean targetLitOnFire = false;
          int fireAspectLevel =
              EnchantmentHelper.getFireAspectModifier((EntityPlayer) (Object) this);

          if (targetEntity instanceof EntityLivingBase
              && fireAspectLevel > 0
              && !targetEntity.isBurning()) {
            targetLitOnFire = true;
            targetEntity.setFire(1);
          }

          double targetMotionX = targetEntity.motionX;
          double targetMotionY = targetEntity.motionY;
          double targetMotionZ = targetEntity.motionZ;

          // Sponge Start - Create the event and throw it
          final DamageSource damageSource =
              DamageSource.causePlayerDamage((EntityPlayer) (Object) this);
          final AttackEntityEvent event =
              SpongeEventFactory.createAttackEntityEvent(
                  Cause.source(damageSource).build(),
                  originalFunctions,
                  EntityUtil.fromNative(targetEntity),
                  knockbackModifier,
                  originalBaseDamage);
          SpongeImpl.postEvent(event);
          if (event.isCancelled()) {
            if (targetLitOnFire) {
              targetEntity.extinguish();
            }
            return;
          }
          baseDamage = (float) event.getFinalOutputDamage();
          knockbackModifier = event.getKnockbackModifier();
          boolean attackSucceded =
              targetEntity.attackEntityFrom(damageSource, (float) event.getFinalOutputDamage());
          // Sponge End
          if (attackSucceded) {
            if (knockbackModifier > 0) {
              targetEntity.addVelocity(
                  (double)
                      (-MathHelper.sin(this.rotationYaw * (float) Math.PI / 180.0F)
                          * (float) knockbackModifier
                          * 0.5F),
                  0.1D,
                  (double)
                      (MathHelper.cos(this.rotationYaw * (float) Math.PI / 180.0F)
                          * (float) knockbackModifier
                          * 0.5F));
              this.motionX *= 0.6D;
              this.motionZ *= 0.6D;
              this.setSprinting(false);
            }

            if (targetEntity instanceof EntityPlayerMP && targetEntity.velocityChanged) {
              ((EntityPlayerMP) targetEntity)
                  .playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(targetEntity));
              targetEntity.velocityChanged = false;
              targetEntity.motionX = targetMotionX;
              targetEntity.motionY = targetMotionY;
              targetEntity.motionZ = targetMotionZ;
            }

            if (fallingCriticalHit) {
              this.onCriticalHit(targetEntity);
            }

            if (enchantmentModifierAmount > 0.0F) {
              this.onEnchantmentCritical(targetEntity);
            }

            if (baseDamage >= 18.0F) {
              this.triggerAchievement(AchievementList.overkill);
            }

            this.setLastAttacker(targetEntity);

            if (targetEntity instanceof EntityLivingBase) {
              EnchantmentHelper.applyThornEnchantments(
                  (EntityLivingBase) targetEntity, (EntityPlayer) (Object) this);
            }

            EnchantmentHelper.applyArthropodEnchantments(
                (EntityPlayer) (Object) this, targetEntity);
            ItemStack itemstack = this.getCurrentEquippedItem();
            net.minecraft.entity.Entity entity = targetEntity;

            if (targetEntity instanceof EntityDragonPart) {
              IEntityMultiPart ientitymultipart = ((EntityDragonPart) targetEntity).entityDragonObj;

              if (ientitymultipart instanceof EntityLivingBase) {
                entity = (EntityLivingBase) ientitymultipart;
              }
            }

            if (itemstack != null && entity instanceof EntityLivingBase) {
              itemstack.hitEntity((EntityLivingBase) entity, (EntityPlayer) (Object) this);

              if (itemstack.stackSize <= 0) {
                this.destroyCurrentEquippedItem();
              }
            }

            if (targetEntity instanceof EntityLivingBase) {
              this.addStat(StatList.damageDealtStat, Math.round(baseDamage * 10.0F));

              if (fireAspectLevel > 0) {
                targetEntity.setFire(fireAspectLevel * 4);
              }
            }

            this.addExhaustion(0.3F);
          } else if (targetLitOnFire) {
            targetEntity.extinguish();
          }
        }
      }
    }
  }