public boolean canSeeNode(Entity entity) {
   return (worldObj.rayTraceBlocks_do(
           Vec3D.createVector(posX, posY - yOffset + 0.5, posZ),
           Vec3D.createVector(entity.posX, entity.posY - entity.yOffset, entity.posZ),
           false)
       == null);
 }
 public boolean canEntityBeSeen(Entity entity) {
   return worldObj.rayTraceBlocks(
           Vec3D.createVector(posX, posY + (double) getEyeHeight(), posZ),
           Vec3D.createVector(
               entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ))
       == null;
 }
 // through doors etc, from knee to knee height
 public boolean canEntityBeSeen2(Entity entity) {
   // System.out.println(getEyeHeight());
   return worldObj.rayTraceBlocks_do(
           Vec3D.createVector(posX, posY - yOffset + 0.7, posZ),
           Vec3D.createVector(entity.posX, entity.posY - entity.yOffset + 0.7, entity.posZ),
           false)
       == null;
 }
 public Vec3D getPosition(float f) {
   if (f == 1.0F) {
     return Vec3D.createVector(posX, posY, posZ);
   } else {
     double d = prevPosX + (posX - prevPosX) * (double) f;
     double d1 = prevPosY + (posY - prevPosY) * (double) f;
     double d2 = prevPosZ + (posZ - prevPosZ) * (double) f;
     return Vec3D.createVector(d, d1, d2);
   }
 }
 // through doors at eye height
 public boolean canEntityBeSeen3(Entity entity) {
   return worldObj.rayTraceBlocks_do(
           Vec3D.createVector(posX, posY - yOffset + (double) getEyeHeight(), posZ),
           Vec3D.createVector(
               entity.posX,
               entity.posY - entity.yOffset + (double) entity.getEyeHeight(),
               entity.posZ),
           false)
       == null;
 }
  // through doors at knee height, and on the same posy level
  public boolean canEntityBeSeen4(Entity entity) {

    // System.out.println((float)((posY-yOffset) - (entity.posY-entity.yOffset)));

    return (worldObj.rayTraceBlocks_do(
                Vec3D.createVector(posX, posY - yOffset + 0.7, posZ),
                Vec3D.createVector(entity.posX, entity.posY - entity.yOffset + 0.7, entity.posZ),
                false)
            == null
        && MathHelper.abs((float) ((posY - yOffset) - (entity.posY - entity.yOffset))) < 1.1F);
  }
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    targetEntity = theEntity.getAttackTarget();

    if (targetEntity == null) {
      return false;
    }

    if (targetEntity.getDistanceSqToEntity(theEntity) > (double) (field_48218_g * field_48218_g)) {
      return false;
    }

    Vec3D vec3d =
        RandomPositionGenerator.func_48395_a(
            theEntity,
            16,
            7,
            Vec3D.createVector(targetEntity.posX, targetEntity.posY, targetEntity.posZ));

    if (vec3d == null) {
      return false;
    } else {
      movePosX = vec3d.xCoord;
      movePosY = vec3d.yCoord;
      movePosZ = vec3d.zCoord;
      return true;
    }
  }
Пример #8
0
  /** Execute a one shot task or start executing a continuous task */
  public void startExecuting() {
    this.insidePosX = -1;

    if (this.entityObj.getDistanceSq(
            (double) this.doorInfo.getInsidePosX(),
            (double) this.doorInfo.posY,
            (double) this.doorInfo.getInsidePosZ())
        > 256.0D) {
      Vec3D var1 =
          RandomPositionGenerator.func_48620_a(
              this.entityObj,
              14,
              3,
              Vec3D.createVector(
                  (double) this.doorInfo.getInsidePosX() + 0.5D,
                  (double) this.doorInfo.getInsidePosY(),
                  (double) this.doorInfo.getInsidePosZ() + 0.5D));

      if (var1 != null) {
        this.entityObj.getNavigator().tryMoveToXYZ(var1.xCoord, var1.yCoord, var1.zCoord, 0.3F);
      }
    } else {
      this.entityObj
          .getNavigator()
          .tryMoveToXYZ(
              (double) this.doorInfo.getInsidePosX() + 0.5D,
              (double) this.doorInfo.getInsidePosY(),
              (double) this.doorInfo.getInsidePosZ() + 0.5D,
              0.3F);
    }
  }
Пример #9
0
 public MovingObjectPosition(int par1, int par2, int par3, int par4, Vec3D par5Vec3D) {
   typeOfHit = EnumMovingObjectType.TILE;
   blockX = par1;
   blockY = par2;
   blockZ = par3;
   sideHit = par4;
   hitVec = Vec3D.createVector(par5Vec3D.xCoord, par5Vec3D.yCoord, par5Vec3D.zCoord);
 }
 public Vec3D getLook(float f) {
   if (f == 1.0F) {
     float f1 = MathHelper.cos(-rotationYaw * 0.01745329F - 3.141593F);
     float f3 = MathHelper.sin(-rotationYaw * 0.01745329F - 3.141593F);
     float f5 = -MathHelper.cos(-rotationPitch * 0.01745329F);
     float f7 = MathHelper.sin(-rotationPitch * 0.01745329F);
     return Vec3D.createVector(f3 * f5, f7, f1 * f5);
   } else {
     float f2 = prevRotationPitch + (rotationPitch - prevRotationPitch) * f;
     float f4 = prevRotationYaw + (rotationYaw - prevRotationYaw) * f;
     float f6 = MathHelper.cos(-f4 * 0.01745329F - 3.141593F);
     float f8 = MathHelper.sin(-f4 * 0.01745329F - 3.141593F);
     float f9 = -MathHelper.cos(-f2 * 0.01745329F);
     float f10 = MathHelper.sin(-f2 * 0.01745329F);
     return Vec3D.createVector(f8 * f9, f10, f6 * f9);
   }
 }
Пример #11
0
  protected void func_35201_a(ItemStack itemstack, int i) {
    if (itemstack.getItemUseAction() == EnumAction.drink) {
      worldObj.playSoundAtEntity(
          this, "random.drink", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F);
    }
    if (itemstack.getItemUseAction() == EnumAction.eat) {
      for (int j = 0; j < i; j++) {
        Vec3D vec3d =
            Vec3D.createVector(
                ((double) rand.nextFloat() - 0.5D) * 0.10000000000000001D,
                Math.random() * 0.10000000000000001D + 0.10000000000000001D,
                0.0D);
        vec3d.rotateAroundX((-rotationPitch * 3.141593F) / 180F);
        vec3d.rotateAroundY((-rotationYaw * 3.141593F) / 180F);
        Vec3D vec3d1 =
            Vec3D.createVector(
                ((double) rand.nextFloat() - 0.5D) * 0.29999999999999999D,
                (double) (-rand.nextFloat()) * 0.59999999999999998D - 0.29999999999999999D,
                0.59999999999999998D);
        vec3d1.rotateAroundX((-rotationPitch * 3.141593F) / 180F);
        vec3d1.rotateAroundY((-rotationYaw * 3.141593F) / 180F);
        vec3d1 = vec3d1.addVector(posX, posY + (double) getEyeHeight(), posZ);
        worldObj.spawnParticle(
            (new StringBuilder())
                .append("iconcrack_")
                .append(itemstack.getItem().shiftedIndex)
                .toString(),
            vec3d1.xCoord,
            vec3d1.yCoord,
            vec3d1.zCoord,
            vec3d.xCoord,
            vec3d.yCoord + 0.050000000000000003D,
            vec3d.zCoord);
      }

      worldObj.playSoundAtEntity(
          this,
          "random.eat",
          0.5F + 0.5F * (float) rand.nextInt(2),
          (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
    }
  }
Пример #12
0
  /** Plays sounds and makes particles for item in use state */
  protected void updateItemUse(ItemStack par1ItemStack, int par2) {
    if (par1ItemStack.getItemUseAction() == EnumAction.drink) {
      this.worldObj.playSoundAtEntity(
          this, "random.drink", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
    }

    if (par1ItemStack.getItemUseAction() == EnumAction.eat) {
      for (int var3 = 0; var3 < par2; ++var3) {
        Vec3D var4 =
            Vec3D.createVector(
                ((double) this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
        var4.rotateAroundX(-this.rotationPitch * (float) Math.PI / 180.0F);
        var4.rotateAroundY(-this.rotationYaw * (float) Math.PI / 180.0F);
        Vec3D var5 =
            Vec3D.createVector(
                ((double) this.rand.nextFloat() - 0.5D) * 0.3D,
                (double) (-this.rand.nextFloat()) * 0.6D - 0.3D,
                0.6D);
        var5.rotateAroundX(-this.rotationPitch * (float) Math.PI / 180.0F);
        var5.rotateAroundY(-this.rotationYaw * (float) Math.PI / 180.0F);
        var5 = var5.addVector(this.posX, this.posY + (double) this.getEyeHeight(), this.posZ);
        this.worldObj.spawnParticle(
            "iconcrack_" + par1ItemStack.getItem().shiftedIndex,
            var5.xCoord,
            var5.yCoord,
            var5.zCoord,
            var4.xCoord,
            var4.yCoord + 0.05D,
            var4.zCoord);
      }

      this.worldObj.playSoundAtEntity(
          this,
          "random.eat",
          0.5F + 0.5F * (float) this.rand.nextInt(2),
          (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
    }
  }
Пример #13
0
 public static Vec3D projectViewFromEntity(EntityLiving par0EntityLiving, double par1) {
   double var3 =
       par0EntityLiving.prevPosX + (par0EntityLiving.posX - par0EntityLiving.prevPosX) * par1;
   double var5 =
       par0EntityLiving.prevPosY
           + (par0EntityLiving.posY - par0EntityLiving.prevPosY) * par1
           + (double) par0EntityLiving.getEyeHeight();
   double var7 =
       par0EntityLiving.prevPosZ + (par0EntityLiving.posZ - par0EntityLiving.prevPosZ) * par1;
   double var9 = var3 + (double) (objectX * 1.0F);
   double var11 = var5 + (double) (objectY * 1.0F);
   double var13 = var7 + (double) (objectZ * 1.0F);
   return Vec3D.createVector(var9, var11, var13);
 }
Пример #14
0
  /** Returns whether the EntityAIBase should begin execution. */
  public boolean shouldExecute() {
    if (this.targetEntityClass == EntityPlayer.class) {
      if (this.theEntity instanceof EntityTameable && ((EntityTameable) this.theEntity).isTamed()) {
        return false;
      }

      this.field_48233_d =
          this.theEntity.worldObj.getClosestPlayerToEntity(
              this.theEntity, (double) this.field_48234_e);

      if (this.field_48233_d == null) {
        return false;
      }
    } else {
      List var1 =
          this.theEntity.worldObj.getEntitiesWithinAABB(
              this.targetEntityClass,
              this.theEntity.boundingBox.expand(
                  (double) this.field_48234_e, 3.0D, (double) this.field_48234_e));

      if (var1.size() == 0) {
        return false;
      }

      this.field_48233_d = (Entity) var1.get(0);
    }

    if (!this.theEntity.getEntitySenses().canSee(this.field_48233_d)) {
      return false;
    } else {
      Vec3D var2 =
          RandomPositionGenerator.func_48394_b(
              this.theEntity,
              16,
              7,
              Vec3D.createVector(
                  this.field_48233_d.posX, this.field_48233_d.posY, this.field_48233_d.posZ));

      if (var2 == null) {
        return false;
      } else if (this.field_48233_d.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord)
          < this.field_48233_d.getDistanceSqToEntity(this.theEntity)) {
        return false;
      } else {
        this.field_48231_f =
            this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord);
        return this.field_48231_f == null ? false : this.field_48231_f.isDestinationSame(var2);
      }
    }
  }
Пример #15
0
 public Vec3D getFogColor(float f, float f1) {
   int i = 0x8080a0;
   float f2 = MathHelper.cos(f * 3.141593F * 2.0F) * 2.0F + 0.5F;
   if (f2 < 0.0F) {
     f2 = 0.0F;
   }
   if (f2 > 1.0F) {
     f2 = 1.0F;
   }
   float f3 = (float) (i >> 16 & 0xff) / 255F;
   float f4 = (float) (i >> 8 & 0xff) / 255F;
   float f5 = (float) (i & 0xff) / 255F;
   f3 *= f2 * 0.0F + 0.15F;
   f4 *= f2 * 0.0F + 0.15F;
   f5 *= f2 * 0.0F + 0.15F;
   return Vec3D.createVector(f3, f4, f5);
 }
Пример #16
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    super.onUpdate();

    if (this.fishPosRotationIncrements > 0) {
      double var21 = this.posX + (this.fishX - this.posX) / (double) this.fishPosRotationIncrements;
      double var22 = this.posY + (this.fishY - this.posY) / (double) this.fishPosRotationIncrements;
      double var23 = this.posZ + (this.fishZ - this.posZ) / (double) this.fishPosRotationIncrements;
      double var7;

      for (var7 = this.fishYaw - (double) this.rotationYaw; var7 < -180.0D; var7 += 360.0D) {;
      }

      while (var7 >= 180.0D) {
        var7 -= 360.0D;
      }

      this.rotationYaw =
          (float) ((double) this.rotationYaw + var7 / (double) this.fishPosRotationIncrements);
      this.rotationPitch =
          (float)
              ((double) this.rotationPitch
                  + (this.fishPitch - (double) this.rotationPitch)
                      / (double) this.fishPosRotationIncrements);
      --this.fishPosRotationIncrements;
      this.setPosition(var21, var22, var23);
      this.setRotation(this.rotationYaw, this.rotationPitch);
    } else {
      if (!this.worldObj.isRemote) {
        ItemStack var1 = this.angler.getCurrentEquippedItem();

        if (this.angler.isDead
            || !this.angler.isEntityAlive()
            || var1 == null
            || var1.getItem() != Item.fishingRod
            || this.getDistanceSqToEntity(this.angler) > 1024.0D) {
          this.setDead();
          this.angler.fishEntity = null;
          return;
        }

        if (this.bobber != null) {
          if (!this.bobber.isDead) {
            this.posX = this.bobber.posX;
            this.posY = this.bobber.boundingBox.minY + (double) this.bobber.height * 0.8D;
            this.posZ = this.bobber.posZ;
            return;
          }

          this.bobber = null;
        }
      }

      if (this.shake > 0) {
        --this.shake;
      }

      if (this.inGround) {
        int var19 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);

        if (var19 == this.inTile) {
          ++this.ticksInGround;

          if (this.ticksInGround == 1200) {
            this.setDead();
          }

          return;
        }

        this.inGround = false;
        this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      } else {
        ++this.ticksInAir;
      }

      Vec3D var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      Vec3D var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var20, var2);
      var20 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (var3 != null) {
        var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
      }

      Entity var4 = null;
      List var5 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var6 = 0.0D;
      double var13;

      for (int var8 = 0; var8 < var5.size(); ++var8) {
        Entity var9 = (Entity) var5.get(var8);

        if (var9.canBeCollidedWith() && (var9 != this.angler || this.ticksInAir >= 5)) {
          float var10 = 0.3F;
          AxisAlignedBB var11 =
              var9.boundingBox.expand((double) var10, (double) var10, (double) var10);
          MovingObjectPosition var12 = var11.calculateIntercept(var20, var2);

          if (var12 != null) {
            var13 = var20.distanceTo(var12.hitVec);

            if (var13 < var6 || var6 == 0.0D) {
              var4 = var9;
              var6 = var13;
            }
          }
        }
      }

      if (var4 != null) {
        var3 = new MovingObjectPosition(var4);
      }

      if (var3 != null) {
        if (var3.entityHit != null) {
          if (var3.entityHit.attackEntityFrom(
              DamageSource.causeThrownDamage(this, this.angler), 0)) {
            this.bobber = var3.entityHit;
          }
        } else {
          this.inGround = true;
        }
      }

      if (!this.inGround) {
        this.moveEntity(this.motionX, this.motionY, this.motionZ);
        float var24 =
            MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
        this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

        for (this.rotationPitch =
                (float) (Math.atan2(this.motionY, (double) var24) * 180.0D / Math.PI);
            this.rotationPitch - this.prevRotationPitch < -180.0F;
            this.prevRotationPitch -= 360.0F) {;
        }

        while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
          this.prevRotationPitch += 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
          this.prevRotationYaw -= 360.0F;
        }

        while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
          this.prevRotationYaw += 360.0F;
        }

        this.rotationPitch =
            this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
        this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
        float var25 = 0.92F;

        if (this.onGround || this.isCollidedHorizontally) {
          var25 = 0.5F;
        }

        byte var27 = 5;
        double var26 = 0.0D;

        for (int var29 = 0; var29 < var27; ++var29) {
          double var14 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 0)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          double var16 =
              this.boundingBox.minY
                  + (this.boundingBox.maxY - this.boundingBox.minY)
                      * (double) (var29 + 1)
                      / (double) var27
                  - 0.125D
                  + 0.125D;
          AxisAlignedBB var18 =
              AxisAlignedBB.getBoundingBoxFromPool(
                  this.boundingBox.minX,
                  var14,
                  this.boundingBox.minZ,
                  this.boundingBox.maxX,
                  var16,
                  this.boundingBox.maxZ);

          if (this.worldObj.isAABBInMaterial(var18, Material.water)) {
            var26 += 1.0D / (double) var27;
          }
        }

        if (var26 > 0.0D) {
          if (this.ticksCatchable > 0) {
            --this.ticksCatchable;
          } else {
            short var28 = 500;

            if (this.worldObj.canLightningStrikeAt(
                MathHelper.floor_double(this.posX),
                MathHelper.floor_double(this.posY) + 1,
                MathHelper.floor_double(this.posZ))) {
              var28 = 300;
            }

            if (this.rand.nextInt(var28) == 0) {
              this.ticksCatchable = this.rand.nextInt(30) + 10;
              this.motionY -= 0.20000000298023224D;
              this.worldObj.playSoundAtEntity(
                  this,
                  "random.splash",
                  0.25F,
                  1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
              float var30 = (float) MathHelper.floor_double(this.boundingBox.minY);
              int var15;
              float var17;
              float var31;

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "bubble",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY - (double) (this.rand.nextFloat() * 0.2F),
                    this.motionZ);
              }

              for (var15 = 0; (float) var15 < 1.0F + this.width * 20.0F; ++var15) {
                var31 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                var17 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
                this.worldObj.spawnParticle(
                    "splash",
                    this.posX + (double) var31,
                    (double) (var30 + 1.0F),
                    this.posZ + (double) var17,
                    this.motionX,
                    this.motionY,
                    this.motionZ);
              }
            }
          }
        }

        if (this.ticksCatchable > 0) {
          this.motionY -=
              (double) (this.rand.nextFloat() * this.rand.nextFloat() * this.rand.nextFloat())
                  * 0.2D;
        }

        var13 = var26 * 2.0D - 1.0D;
        this.motionY += 0.03999999910593033D * var13;

        if (var26 > 0.0D) {
          var25 = (float) ((double) var25 * 0.9D);
          this.motionY *= 0.8D;
        }

        this.motionX *= (double) var25;
        this.motionY *= (double) var25;
        this.motionZ *= (double) var25;
        this.setPosition(this.posX, this.posY, this.posZ);
      }
    }
  }
Пример #17
0
  public void doRenderFishHook(
      EntityFishHook entityfishhook, double d, double d1, double d2, float f, float f1) {
    GL11.glPushMatrix();
    GL11.glTranslatef((float) d, (float) d1, (float) d2);
    GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/);
    GL11.glScalef(0.5F, 0.5F, 0.5F);
    int i = 1;
    byte byte0 = 2;
    loadTexture("/particles.png");
    Tessellator tessellator = Tessellator.instance;
    float f2 = (float) (i * 8 + 0) / 128F;
    float f3 = (float) (i * 8 + 8) / 128F;
    float f4 = (float) (byte0 * 8 + 0) / 128F;
    float f5 = (float) (byte0 * 8 + 8) / 128F;
    float f6 = 1.0F;
    float f7 = 0.5F;
    float f8 = 0.5F;
    GL11.glRotatef(180F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    tessellator.addVertexWithUV(0.0F - f7, 0.0F - f8, 0.0D, f2, f5);
    tessellator.addVertexWithUV(f6 - f7, 0.0F - f8, 0.0D, f3, f5);
    tessellator.addVertexWithUV(f6 - f7, 1.0F - f8, 0.0D, f3, f4);
    tessellator.addVertexWithUV(0.0F - f7, 1.0F - f8, 0.0D, f2, f4);
    tessellator.draw();
    GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/);
    GL11.glPopMatrix();
    if (entityfishhook.angler != null) {
      float f9 =
          ((entityfishhook.angler.prevRotationYaw
                      + (entityfishhook.angler.rotationYaw - entityfishhook.angler.prevRotationYaw)
                          * f1)
                  * 3.141593F)
              / 180F;
      double d3 = MathHelper.sin(f9);
      double d5 = MathHelper.cos(f9);
      float f11 = entityfishhook.angler.getSwingProgress(f1);
      float f12 = MathHelper.sin(MathHelper.sqrt_float(f11) * 3.141593F);
      Vec3D vec3d = Vec3D.createVector(-0.5D, 0.029999999999999999D, 0.80000000000000004D);
      vec3d.rotateAroundX(
          (-(entityfishhook.angler.prevRotationPitch
                      + (entityfishhook.angler.rotationPitch
                              - entityfishhook.angler.prevRotationPitch)
                          * f1)
                  * 3.141593F)
              / 180F);
      vec3d.rotateAroundY(
          (-(entityfishhook.angler.prevRotationYaw
                      + (entityfishhook.angler.rotationYaw - entityfishhook.angler.prevRotationYaw)
                          * f1)
                  * 3.141593F)
              / 180F);
      vec3d.rotateAroundY(f12 * 0.5F);
      vec3d.rotateAroundX(-f12 * 0.7F);
      double d7 =
          entityfishhook.angler.prevPosX
              + (entityfishhook.angler.posX - entityfishhook.angler.prevPosX) * (double) f1
              + vec3d.xCoord;
      double d8 =
          entityfishhook.angler.prevPosY
              + (entityfishhook.angler.posY - entityfishhook.angler.prevPosY) * (double) f1
              + vec3d.yCoord;
      double d9 =
          entityfishhook.angler.prevPosZ
              + (entityfishhook.angler.posZ - entityfishhook.angler.prevPosZ) * (double) f1
              + vec3d.zCoord;
      if (renderManager.options.thirdPersonView > 0) {
        float f10 =
            ((entityfishhook.angler.prevRenderYawOffset
                        + (entityfishhook.angler.renderYawOffset
                                - entityfishhook.angler.prevRenderYawOffset)
                            * f1)
                    * 3.141593F)
                / 180F;
        double d4 = MathHelper.sin(f10);
        double d6 = MathHelper.cos(f10);
        d7 =
            (entityfishhook.angler.prevPosX
                    + (entityfishhook.angler.posX - entityfishhook.angler.prevPosX) * (double) f1)
                - d6 * 0.34999999999999998D
                - d4 * 0.84999999999999998D;
        d8 =
            (entityfishhook.angler.prevPosY
                    + (entityfishhook.angler.posY - entityfishhook.angler.prevPosY) * (double) f1)
                - 0.45000000000000001D;
        d9 =
            ((entityfishhook.angler.prevPosZ
                        + (entityfishhook.angler.posZ - entityfishhook.angler.prevPosZ)
                            * (double) f1)
                    - d4 * 0.34999999999999998D)
                + d6 * 0.84999999999999998D;
      }
      double d10 =
          entityfishhook.prevPosX + (entityfishhook.posX - entityfishhook.prevPosX) * (double) f1;
      double d11 =
          entityfishhook.prevPosY
              + (entityfishhook.posY - entityfishhook.prevPosY) * (double) f1
              + 0.25D;
      double d12 =
          entityfishhook.prevPosZ + (entityfishhook.posZ - entityfishhook.prevPosZ) * (double) f1;
      double d13 = (float) (d7 - d10);
      double d14 = (float) (d8 - d11);
      double d15 = (float) (d9 - d12);
      GL11.glDisable(3553 /*GL_TEXTURE_2D*/);
      GL11.glDisable(2896 /*GL_LIGHTING*/);
      tessellator.startDrawing(3);
      tessellator.setColorOpaque_I(0);
      int j = 16;
      for (int k = 0; k <= j; k++) {
        float f13 = (float) k / (float) j;
        tessellator.addVertex(
            d + d13 * (double) f13,
            d1 + d14 * (double) (f13 * f13 + f13) * 0.5D + 0.25D,
            d2 + d15 * (double) f13);
      }

      tessellator.draw();
      GL11.glEnable(2896 /*GL_LIGHTING*/);
      GL11.glEnable(3553 /*GL_TEXTURE_2D*/);
    }
  }
Пример #18
0
 public MovingObjectPosition(Entity par1Entity) {
   typeOfHit = EnumMovingObjectType.ENTITY;
   entityHit = par1Entity;
   hitVec = Vec3D.createVector(par1Entity.posX, par1Entity.posY, par1Entity.posZ);
 }
Пример #19
0
  /** Called to update the entity's position/logic. */
  public void onUpdate() {
    if (!worldObj.isRemote
        && (shootingEntity != null && shootingEntity.isDead
            || !worldObj.blockExists((int) posX, (int) posY, (int) posZ))) {
      setDead();
      return;
    }

    super.onUpdate();
    setFire(1);

    if (inGround) {
      int i = worldObj.getBlockId(xTile, yTile, zTile);

      if (i != inTile) {
        inGround = false;
        motionX *= rand.nextFloat() * 0.2F;
        motionY *= rand.nextFloat() * 0.2F;
        motionZ *= rand.nextFloat() * 0.2F;
        ticksAlive = 0;
        ticksInAir = 0;
      } else {
        ticksAlive++;

        if (ticksAlive == 600) {
          setDead();
        }

        return;
      }
    } else {
      ticksInAir++;
    }

    Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
    Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3D.createVector(posX, posY, posZ);
    vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);

    if (movingobjectposition != null) {
      vec3d1 =
          Vec3D.createVector(
              movingobjectposition.hitVec.xCoord,
              movingobjectposition.hitVec.yCoord,
              movingobjectposition.hitVec.zCoord);
    }

    Entity entity = null;
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;

    for (int j = 0; j < list.size(); j++) {
      Entity entity1 = (Entity) list.get(j);

      if (!entity1.canBeCollidedWith()
          || entity1.isEntityEqual(shootingEntity) && ticksInAir < 25) {
        continue;
      }

      float f2 = 0.3F;
      AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
      MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);

      if (movingobjectposition1 == null) {
        continue;
      }

      double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);

      if (d1 < d || d == 0.0D) {
        entity = entity1;
        d = d1;
      }
    }

    if (entity != null) {
      movingobjectposition = new MovingObjectPosition(entity);
    }

    if (movingobjectposition != null) {
      func_40063_a(movingobjectposition);
    }

    posX += motionX;
    posY += motionY;
    posZ += motionZ;
    float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / Math.PI);

    for (rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / Math.PI);
        rotationPitch - prevRotationPitch < -180F;
        prevRotationPitch -= 360F) {}

    for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {}

    for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {}

    for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {}

    rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
    rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
    float f1 = 0.95F;

    if (isInWater()) {
      for (int k = 0; k < 4; k++) {
        float f3 = 0.25F;
        worldObj.spawnParticle(
            "bubble",
            posX - motionX * (double) f3,
            posY - motionY * (double) f3,
            posZ - motionZ * (double) f3,
            motionX,
            motionY,
            motionZ);
      }

      f1 = 0.8F;
    }

    motionX += accelerationX;
    motionY += accelerationY;
    motionZ += accelerationZ;
    motionX *= f1;
    motionY *= f1;
    motionZ *= f1;
    worldObj.spawnParticle("smoke", posX, posY + 0.5D, posZ, 0.0D, 0.0D, 0.0D);
    setPosition(posX, posY, posZ);
  }
Пример #20
0
  public void onUpdate() {
    if (!this.worldObj.isRemote
        && (this.shootingEntity != null && this.shootingEntity.isDead
            || !this.worldObj.blockExists((int) this.posX, (int) this.posY, (int) this.posZ))) {
      this.setDead();
    } else {
      super.onUpdate();
      this.setFire(1);
      if (this.inGround) {
        int var1 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile);
        if (var1 == this.inTile) {
          ++this.ticksAlive;
          if (this.ticksAlive == 600) {
            this.setDead();
          }

          return;
        }

        this.inGround = false;
        this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
        this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
        this.ticksAlive = 0;
        this.ticksInAir = 0;
      } else {
        ++this.ticksInAir;
      }

      Vec3D var15 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      Vec3D var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var15, var2);
      var15 = Vec3D.createVector(this.posX, this.posY, this.posZ);
      var2 =
          Vec3D.createVector(
              this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      if (var3 != null) {
        var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord);
      }

      Entity var4 = null;
      List var5 =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.boundingBox
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double var6 = 0.0D;

      for (int var8 = 0; var8 < var5.size(); ++var8) {
        Entity var9 = (Entity) var5.get(var8);
        if (var9.canBeCollidedWith()
            && (!var9.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) {
          float var10 = 0.3F;
          AxisAlignedBB var11 =
              var9.boundingBox.expand((double) var10, (double) var10, (double) var10);
          MovingObjectPosition var12 = var11.calculateIntercept(var15, var2);
          if (var12 != null) {
            double var13 = var15.distanceTo(var12.hitVec);
            if (var13 < var6 || var6 == 0.0D) {
              var4 = var9;
              var6 = var13;
            }
          }
        }
      }

      if (var4 != null) {
        var3 = new MovingObjectPosition(var4);
      }

      if (var3 != null) {
        this.func_40071_a(var3);
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      float var16 =
          MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);

      for (this.rotationPitch =
              (float) (Math.atan2(this.motionY, (double) var16) * 180.0D / Math.PI);
          this.rotationPitch - this.prevRotationPitch < -180.0F;
          this.prevRotationPitch -= 360.0F) {;
      }

      while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
        this.prevRotationPitch += 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
        this.prevRotationYaw -= 360.0F;
      }

      while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
        this.prevRotationYaw += 360.0F;
      }

      this.rotationPitch =
          this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
      this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
      float var17 = 0.95F;
      if (this.isInWater()) {
        for (int var19 = 0; var19 < 4; ++var19) {
          float var18 = 0.25F;
          this.worldObj.spawnParticle(
              "bubble",
              this.posX - this.motionX * (double) var18,
              this.posY - this.motionY * (double) var18,
              this.posZ - this.motionZ * (double) var18,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        var17 = 0.8F;
      }

      this.motionX += this.accelerationX;
      this.motionY += this.accelerationY;
      this.motionZ += this.accelerationZ;
      this.motionX *= (double) var17;
      this.motionY *= (double) var17;
      this.motionZ *= (double) var17;
      this.worldObj.spawnParticle(
          "smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
      this.setPosition(this.posX, this.posY, this.posZ);
    }
  }
Пример #21
0
  public Vec3D func_182_g(double par1, double par3, double par5) {
    int i = MathHelper.floor_double(par1);
    int j = MathHelper.floor_double(par3);
    int k = MathHelper.floor_double(par5);

    if (BlockRail.isRailBlockAt(worldObj, i, j - 1, k)) {
      j--;
    }

    int l = worldObj.getBlockId(i, j, k);

    if (BlockRail.isRailBlock(l)) {
      int i1 = worldObj.getBlockMetadata(i, j, k);
      par3 = j;

      if (((BlockRail) Block.blocksList[l]).isPowered()) {
        i1 &= 7;
      }

      if (i1 >= 2 && i1 <= 5) {
        par3 = j + 1;
      }

      int ai[][] = field_468_ak[i1];
      double d = 0.0D;
      double d1 = (double) i + 0.5D + (double) ai[0][0] * 0.5D;
      double d2 = (double) j + 0.5D + (double) ai[0][1] * 0.5D;
      double d3 = (double) k + 0.5D + (double) ai[0][2] * 0.5D;
      double d4 = (double) i + 0.5D + (double) ai[1][0] * 0.5D;
      double d5 = (double) j + 0.5D + (double) ai[1][1] * 0.5D;
      double d6 = (double) k + 0.5D + (double) ai[1][2] * 0.5D;
      double d7 = d4 - d1;
      double d8 = (d5 - d2) * 2D;
      double d9 = d6 - d3;

      if (d7 == 0.0D) {
        par1 = (double) i + 0.5D;
        d = par5 - (double) k;
      } else if (d9 == 0.0D) {
        par5 = (double) k + 0.5D;
        d = par1 - (double) i;
      } else {
        double d10 = par1 - d1;
        double d11 = par5 - d3;
        double d12 = (d10 * d7 + d11 * d9) * 2D;
        d = d12;
      }

      par1 = d1 + d7 * d;
      par3 = d2 + d8 * d;
      par5 = d3 + d9 * d;

      if (d8 < 0.0D) {
        par3++;
      }

      if (d8 > 0.0D) {
        par3 += 0.5D;
      }

      return Vec3D.createVector(par1, par3, par5);
    } else {
      return null;
    }
  }
  public void doExplosion() {
    float f = explosionSize;
    int i = 16;
    for (int j = 0; j < i; j++) {
      for (int l = 0; l < i; l++) {
        label0:
        for (int j1 = 0; j1 < i; j1++) {
          if (j != 0 && j != i - 1 && l != 0 && l != i - 1 && j1 != 0 && j1 != i - 1) {
            continue;
          }
          double d = ((float) j / ((float) i - 1.0F)) * 2.0F - 1.0F;
          double d1 = ((float) l / ((float) i - 1.0F)) * 2.0F - 1.0F;
          double d2 = ((float) j1 / ((float) i - 1.0F)) * 2.0F - 1.0F;
          double d3 = Math.sqrt(d * d + d1 * d1 + d2 * d2);
          d /= d3;
          d1 /= d3;
          d2 /= d3;
          float f1 = explosionSize * (0.7F + worldObj.rand.nextFloat() * 0.6F);
          double d5 = explosionX;
          double d7 = explosionY;
          double d9 = explosionZ;
          float f2 = 0.3F;
          do {
            if (f1 <= 0.0F) {
              continue label0;
            }
            int j4 = MathHelper.floor_double(d5);
            int k4 = MathHelper.floor_double(d7);
            int l4 = MathHelper.floor_double(d9);
            int i5 = worldObj.getBlockId(j4, k4, l4);
            if (i5 > 0) {
              f1 -= (Block.blocksList[i5].getExplosionResistance(exploder) + 0.3F) * f2;
            }
            if (f1 > 0.0F) {
              destroyedBlockPositions.add(new ChunkPosition(j4, k4, l4));
            }
            d5 += d * (double) f2;
            d7 += d1 * (double) f2;
            d9 += d2 * (double) f2;
            f1 -= f2 * 0.75F;
          } while (true);
        }
      }
    }

    explosionSize *= 2.0F;
    int k = MathHelper.floor_double(explosionX - (double) explosionSize - 1.0D);
    int i1 = MathHelper.floor_double(explosionX + (double) explosionSize + 1.0D);
    int k1 = MathHelper.floor_double(explosionY - (double) explosionSize - 1.0D);
    int l1 = MathHelper.floor_double(explosionY + (double) explosionSize + 1.0D);
    int i2 = MathHelper.floor_double(explosionZ - (double) explosionSize - 1.0D);
    int j2 = MathHelper.floor_double(explosionZ + (double) explosionSize + 1.0D);
    List list =
        worldObj.getEntitiesWithinAABBExcludingEntity(
            exploder, AxisAlignedBB.getBoundingBoxFromPool(k, k1, i2, i1, l1, j2));
    Vec3D vec3d = Vec3D.createVector(explosionX, explosionY, explosionZ);
    for (int k2 = 0; k2 < list.size(); k2++) {
      Entity entity = (Entity) list.get(k2);
      double d4 = entity.getDistance(explosionX, explosionY, explosionZ) / (double) explosionSize;
      if (d4 <= 1.0D) {
        double d6 = entity.posX - explosionX;
        double d8 = entity.posY - explosionY;
        double d10 = entity.posZ - explosionZ;
        double d11 = MathHelper.sqrt_double(d6 * d6 + d8 * d8 + d10 * d10);
        d6 /= d11;
        d8 /= d11;
        d10 /= d11;
        double d12 = worldObj.func_494_a(vec3d, entity.boundingBox);
        double d13 = (1.0D - d4) * d12;
        entity.attackEntityFrom(
            exploder, (int) (((d13 * d13 + d13) / 2D) * 8D * (double) explosionSize + 1.0D));
        double d14 = d13;
        entity.motionX += d6 * d14;
        entity.motionY += d8 * d14;
        entity.motionZ += d10 * d14;
      }
    }

    explosionSize = f;
    ArrayList arraylist = new ArrayList();
    arraylist.addAll(destroyedBlockPositions);
    if (isFlaming) {
      for (int l2 = arraylist.size() - 1; l2 >= 0; l2--) {
        ChunkPosition chunkposition = (ChunkPosition) arraylist.get(l2);
        int i3 = chunkposition.x;
        int j3 = chunkposition.y;
        int k3 = chunkposition.z;
        int l3 = worldObj.getBlockId(i3, j3, k3);
        int i4 = worldObj.getBlockId(i3, j3 - 1, k3);
        if (l3 == 0 && Block.opaqueCubeLookup[i4] && ExplosionRNG.nextInt(3) == 0) {
          worldObj.setBlockWithNotify(i3, j3, k3, Block.fire.blockID);
        }
      }
    }
  }