Ejemplo n.º 1
0
 public static MovingObjectPosition getTargetBlock(EntityPlayerMP thePlayer) {
   float par1 = 0.1F;
   Vec3 var4 = thePlayer.getPosition(256);
   Vec3 var5 = thePlayer.getLook(256);
   Vec3 var6 = var4.addVector(var5.xCoord * par1, var5.yCoord * par1, var5.zCoord * par1);
   return thePlayer.worldObj.rayTraceBlocks(var4, var6);
 }
 protected boolean func_70816_c(Entity p_70816_1_) {
   Vec3 var2 =
       Vec3.func_72437_a()
           .func_72345_a(
               this.field_70165_t - p_70816_1_.field_70165_t,
               this.field_70121_D.field_72338_b
                   + (double) (this.field_70131_O / 2.0F)
                   - p_70816_1_.field_70163_u
                   + (double) p_70816_1_.func_70047_e(),
               this.field_70161_v - p_70816_1_.field_70161_v);
   var2 = var2.func_72432_b();
   double var3 = 16.0D;
   double var5 =
       this.field_70165_t
           + (this.field_70146_Z.nextDouble() - 0.5D) * 8.0D
           - var2.field_72450_a * var3;
   double var7 =
       this.field_70163_u
           + (double) (this.field_70146_Z.nextInt(16) - 8)
           - var2.field_72448_b * var3;
   double var9 =
       this.field_70161_v
           + (this.field_70146_Z.nextDouble() - 0.5D) * 8.0D
           - var2.field_72449_c * var3;
   return this.func_70825_j(var5, var7, var9);
 }
Ejemplo n.º 3
0
  private Vec3 func_75527_a(int p_75527_1_, int p_75527_2_, int p_75527_3_) {
    for (int var4 = 0; var4 < 10; ++var4) {
      int var5 = p_75527_1_ + this.field_75537_a.field_73012_v.nextInt(16) - 8;
      int var6 = p_75527_2_ + this.field_75537_a.field_73012_v.nextInt(6) - 3;
      int var7 = p_75527_3_ + this.field_75537_a.field_73012_v.nextInt(16) - 8;
      if (this.field_75531_f.func_75570_a(var5, var6, var7)
          && SpawnerAnimals.func_77190_a(
              EnumCreatureType.monster, this.field_75537_a, var5, var6, var7)) {
        return Vec3.func_72437_a().func_72345_a((double) var5, (double) var6, (double) var7);
      }
    }

    return null;
  }
Ejemplo n.º 4
0
  @SideOnly(Side.CLIENT)
  public Vec3 func_76562_b(float p_76562_1_, float p_76562_2_) {
    float var3 = MathHelper.func_76134_b(p_76562_1_ * 3.1415927F * 2.0F) * 2.0F + 0.5F;
    if (var3 < 0.0F) {
      var3 = 0.0F;
    }

    if (var3 > 1.0F) {
      var3 = 1.0F;
    }

    float var4 = 0.7529412F;
    float var5 = 0.84705883F;
    float var6 = 1.0F;
    var4 *= var3 * 0.94F + 0.06F;
    var5 *= var3 * 0.94F + 0.06F;
    var6 *= var3 * 0.91F + 0.09F;
    return Vec3.func_72437_a().func_72345_a((double) var4, (double) var5, (double) var6);
  }
Ejemplo n.º 5
0
  @SideOnly(Side.CLIENT)
  public Vec3 func_76562_b(float p_76562_1_, float p_76562_2_) {
    int var3 = 10518688;
    float var4 = MathHelper.func_76134_b(p_76562_1_ * 3.1415927F * 2.0F) * 2.0F + 0.5F;
    if (var4 < 0.0F) {
      var4 = 0.0F;
    }

    if (var4 > 1.0F) {
      var4 = 1.0F;
    }

    float var5 = (float) (var3 >> 16 & 255) / 255.0F;
    float var6 = (float) (var3 >> 8 & 255) / 255.0F;
    float var7 = (float) (var3 & 255) / 255.0F;
    var5 *= var4 * 0.0F + 0.15F;
    var6 *= var4 * 0.0F + 0.15F;
    var7 *= var4 * 0.0F + 0.15F;
    return Vec3.func_72437_a().func_72345_a((double) var5, (double) var6, (double) var7);
  }
 private boolean func_70821_d(EntityPlayer p_70821_1_) {
   ItemStack var2 = p_70821_1_.field_71071_by.field_70460_b[3];
   if (var2 != null && var2.field_77993_c == Block.field_72061_ba.field_71990_ca) {
     return false;
   } else {
     Vec3 var3 = p_70821_1_.func_70676_i(1.0F).func_72432_b();
     Vec3 var4 =
         Vec3.func_72437_a()
             .func_72345_a(
                 this.field_70165_t - p_70821_1_.field_70165_t,
                 this.field_70121_D.field_72338_b
                     + (double) (this.field_70131_O / 2.0F)
                     - (p_70821_1_.field_70163_u + (double) p_70821_1_.func_70047_e()),
                 this.field_70161_v - p_70821_1_.field_70161_v);
     double var5 = var4.func_72433_c();
     var4 = var4.func_72432_b();
     double var7 = var3.func_72430_b(var4);
     return var7 > 1.0D - 0.025D / var5 ? p_70821_1_.func_70685_l(this) : false;
   }
 }
Ejemplo n.º 7
0
  @Override
  public void onUpdate() {
    super.onUpdate();
    if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
      prevRotationYaw =
          rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
      prevRotationPitch =
          rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
    }
    if (arrowShake > 0) {
      arrowShake--;
    }
    if (inGround) {
      int i = worldObj.getBlockId(xTile, yTile, zTile);
      int j = worldObj.getBlockMetadata(xTile, yTile, zTile);
      if (i != inTile || j != inData) {
        inGround = false;
        motionX *= rand.nextFloat() * 0.2F;
        motionY *= rand.nextFloat() * 0.2F;
        motionZ *= rand.nextFloat() * 0.2F;
        ticksInGround = 0;
        ticksFlying = 0;
      } else {
        ticksInGround++;
        tickInGround();
        if (ticksInGround == ttlInGround) {
          setDead();
        }
        return;
      }
    } else {
      ticksFlying++;
    }
    tickFlying();
    Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
    vec3d = Vec3.createVectorHelper(posX, posY, posZ);
    vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
    if (movingobjectposition != null) {
      vec3d1 =
          Vec3.createVectorHelper(
              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 k = 0; k < list.size(); k++) {
      Entity entity2 = (Entity) list.get(k);
      if (!canBeShot(entity2)) {
        continue;
      }
      float f3 = hitBox;
      AxisAlignedBB axisalignedbb = entity2.boundingBox.expand(f3, f3, f3);
      MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
      if (movingobjectposition1 == null) {
        continue;
      }
      double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
      if (d1 < d || d == 0.0D) {
        entity = entity2;
        d = d1;
      }
    }

    if (entity != null) {
      movingobjectposition = new MovingObjectPosition(entity);
    }
    if (movingobjectposition != null && (entity != shooter || ticksFlying > 2) && (onHit())) {
      Entity entity1 = movingobjectposition.entityHit;
      if (entity1 != null) {
        if (!worldObj.isRemote) {
          if (onHitTarget(entity1) && hasTorchAttachment == false) {
            if ((entity1 instanceof EntityLiving) && !(entity1 instanceof EntityPlayer)) {
              ++((EntityLiving) entity1).arrowHitTempCounter;
            }

            entity1.attackEntityFrom(
                DamageSource.causePlayerDamage((EntityPlayer) shooter),
                this.arrowCritical ? dmg * 2 : dmg);
            setDead();
          }
        }
      } else {
        xTile = movingobjectposition.blockX;
        yTile = movingobjectposition.blockY;
        zTile = movingobjectposition.blockZ;
        inTile = worldObj.getBlockId(xTile, yTile, zTile);
        inData = worldObj.getBlockMetadata(xTile, yTile, zTile);
        Block block = Block.blocksList[inTile];
        if (block != null && !(block instanceof BlockFlower)) {
          if (onHitBlock(movingobjectposition)) {
            motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
            motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
            motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
            float f2 =
                MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
            posX -= (motionX / (double) f2) * 0.05000000074505806D;
            posY -= (motionY / (double) f2) * 0.05000000074505806D;
            posZ -= (motionZ / (double) f2) * 0.05000000074505806D;
            inGround = true;
            arrowShake = 7;
            this.arrowCritical = false;
          }
        }
      }
    }
    if (movingobjectposition != null && !worldObj.isRemote) {
      Entity entity1 = movingobjectposition.entityHit;
      if (entity1 != null && entity1 instanceof EntityLiving && entity1 != shooter) {
        if (hasExplosiveAttachment && ((EntityLiving) entity1).arrowHitTempCounter < 10) {
          this.worldObj.createExplosion(
              this,
              (int) Math.floor(((EntityLiving) entity1).posX),
              (int) ((EntityLiving) entity1).posY,
              (int) Math.floor(((EntityLiving) entity1).posZ),
              1);
        }

        if (hasIceAttachment) {
          ((EntityLiving) entity1)
              .addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 280, 3));
        }

        if (hasPoisonAttachment) {
          ((EntityLiving) entity1).addPotionEffect(new PotionEffect(Potion.poison.id, 280, 3));
        }

        if (hasLightningAttachment) {
          this.worldObj.addWeatherEffect(
              new EntityLightningBolt(this.worldObj, entity1.posX, entity1.posY, entity1.posZ));
          this.setDead();
        }
      }
    }

    FMLLog.info("" + this.inGround);

    posX += motionX;
    posZ += motionZ;
    posY += motionY;
    handleMotionUpdate();
    float f1 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
    rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
    for (rotationPitch = (float) ((Math.atan2(motionY, f1) * 180D) / 3.1415927410125732D);
        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;
    setPosition(posX, posY, posZ);
  }
 public Vec3 func_76562_b(float p_76562_1_, float p_76562_2_) {
   return Vec3.func_72437_a()
       .func_72345_a(0.20000000298023224D, 0.029999999329447746D, 0.029999999329447746D);
 }
Ejemplo n.º 9
0
  public void func_70108_f(Entity p_70108_1_) {
    if (!this.field_70170_p.field_72995_K) {
      if (p_70108_1_ != this.field_70153_n) {
        if (p_70108_1_ instanceof EntityLiving
            && !(p_70108_1_ instanceof EntityPlayer)
            && !(p_70108_1_ instanceof EntityIronGolem)
            && this.func_94087_l() == 0
            && this.field_70159_w * this.field_70159_w + this.field_70179_y * this.field_70179_y
                > 0.01D
            && this.field_70153_n == null
            && p_70108_1_.field_70154_o == null) {
          p_70108_1_.func_70078_a(this);
        }

        double var2 = p_70108_1_.field_70165_t - this.field_70165_t;
        double var4 = p_70108_1_.field_70161_v - this.field_70161_v;
        double var6 = var2 * var2 + var4 * var4;
        if (var6 >= 9.999999747378752E-5D) {
          var6 = (double) MathHelper.func_76133_a(var6);
          var2 /= var6;
          var4 /= var6;
          double var8 = 1.0D / var6;
          if (var8 > 1.0D) {
            var8 = 1.0D;
          }

          var2 *= var8;
          var4 *= var8;
          var2 *= 0.10000000149011612D;
          var4 *= 0.10000000149011612D;
          var2 *= (double) (1.0F - this.field_70144_Y);
          var4 *= (double) (1.0F - this.field_70144_Y);
          var2 *= 0.5D;
          var4 *= 0.5D;
          if (p_70108_1_ instanceof EntityMinecart) {
            double var10 = p_70108_1_.field_70165_t - this.field_70165_t;
            double var12 = p_70108_1_.field_70161_v - this.field_70161_v;
            Vec3 var14 =
                this.field_70170_p.func_82732_R().func_72345_a(var10, 0.0D, var12).func_72432_b();
            Vec3 var15 =
                this.field_70170_p
                    .func_82732_R()
                    .func_72345_a(
                        (double) MathHelper.func_76134_b(this.field_70177_z * 3.1415927F / 180.0F),
                        0.0D,
                        (double) MathHelper.func_76126_a(this.field_70177_z * 3.1415927F / 180.0F))
                    .func_72432_b();
            double var16 = Math.abs(var14.func_72430_b(var15));
            if (var16 < 0.800000011920929D) {
              return;
            }

            double var18 = p_70108_1_.field_70159_w + this.field_70159_w;
            double var20 = p_70108_1_.field_70179_y + this.field_70179_y;
            if (((EntityMinecart) p_70108_1_).func_94087_l() == 2 && this.func_94087_l() != 2) {
              this.field_70159_w *= 0.20000000298023224D;
              this.field_70179_y *= 0.20000000298023224D;
              this.func_70024_g(
                  p_70108_1_.field_70159_w - var2, 0.0D, p_70108_1_.field_70179_y - var4);
              p_70108_1_.field_70159_w *= 0.949999988079071D;
              p_70108_1_.field_70179_y *= 0.949999988079071D;
            } else if (((EntityMinecart) p_70108_1_).func_94087_l() != 2
                && this.func_94087_l() == 2) {
              p_70108_1_.field_70159_w *= 0.20000000298023224D;
              p_70108_1_.field_70179_y *= 0.20000000298023224D;
              p_70108_1_.func_70024_g(this.field_70159_w + var2, 0.0D, this.field_70179_y + var4);
              this.field_70159_w *= 0.949999988079071D;
              this.field_70179_y *= 0.949999988079071D;
            } else {
              var18 /= 2.0D;
              var20 /= 2.0D;
              this.field_70159_w *= 0.20000000298023224D;
              this.field_70179_y *= 0.20000000298023224D;
              this.func_70024_g(var18 - var2, 0.0D, var20 - var4);
              p_70108_1_.field_70159_w *= 0.20000000298023224D;
              p_70108_1_.field_70179_y *= 0.20000000298023224D;
              p_70108_1_.func_70024_g(var18 + var2, 0.0D, var20 + var4);
            }
          } else {
            this.func_70024_g(-var2, 0.0D, -var4);
            p_70108_1_.func_70024_g(var2 / 4.0D, 0.0D, var4 / 4.0D);
          }
        }
      }
    }
  }
Ejemplo n.º 10
0
public class RenderHelper {

  private static FloatBuffer field_74522_a = GLAllocation.func_74529_h(16);
  private static final Vec3 field_82884_b =
      Vec3.func_72443_a(0.20000000298023224D, 1.0D, -0.699999988079071D).func_72432_b();
  private static final Vec3 field_82885_c =
      Vec3.func_72443_a(-0.20000000298023224D, 1.0D, 0.699999988079071D).func_72432_b();

  public static void func_74518_a() {
    GL11.glDisable(2896);
    GL11.glDisable(16384);
    GL11.glDisable(16385);
    GL11.glDisable(2903);
  }

  public static void func_74519_b() {
    GL11.glEnable(2896);
    GL11.glEnable(16384);
    GL11.glEnable(16385);
    GL11.glEnable(2903);
    GL11.glColorMaterial(1032, 5634);
    float var0 = 0.4F;
    float var1 = 0.6F;
    float var2 = 0.0F;
    GL11.glLight(
        16384,
        4611,
        func_74517_a(
            field_82884_b.field_72450_a,
            field_82884_b.field_72448_b,
            field_82884_b.field_72449_c,
            0.0D));
    GL11.glLight(16384, 4609, func_74521_a(var1, var1, var1, 1.0F));
    GL11.glLight(16384, 4608, func_74521_a(0.0F, 0.0F, 0.0F, 1.0F));
    GL11.glLight(16384, 4610, func_74521_a(var2, var2, var2, 1.0F));
    GL11.glLight(
        16385,
        4611,
        func_74517_a(
            field_82885_c.field_72450_a,
            field_82885_c.field_72448_b,
            field_82885_c.field_72449_c,
            0.0D));
    GL11.glLight(16385, 4609, func_74521_a(var1, var1, var1, 1.0F));
    GL11.glLight(16385, 4608, func_74521_a(0.0F, 0.0F, 0.0F, 1.0F));
    GL11.glLight(16385, 4610, func_74521_a(var2, var2, var2, 1.0F));
    GL11.glShadeModel(7424);
    GL11.glLightModel(2899, func_74521_a(var0, var0, var0, 1.0F));
  }

  private static FloatBuffer func_74517_a(
      double p_74517_0_, double p_74517_2_, double p_74517_4_, double p_74517_6_) {
    return func_74521_a(
        (float) p_74517_0_, (float) p_74517_2_, (float) p_74517_4_, (float) p_74517_6_);
  }

  private static FloatBuffer func_74521_a(
      float p_74521_0_, float p_74521_1_, float p_74521_2_, float p_74521_3_) {
    field_74522_a.clear();
    field_74522_a.put(p_74521_0_).put(p_74521_1_).put(p_74521_2_).put(p_74521_3_);
    field_74522_a.flip();
    return field_74522_a;
  }

  public static void func_74520_c() {
    GL11.glPushMatrix();
    GL11.glRotatef(-30.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(165.0F, 1.0F, 0.0F, 0.0F);
    func_74519_b();
    GL11.glPopMatrix();
  }
}