示例#1
0
  private ItemStack getFishingResult() {
    float f = this.worldObj.rand.nextFloat();
    int i = EnchantmentHelper.getLuckOfSeaModifier(this.angler);
    int j = EnchantmentHelper.getLureModifier(this.angler);
    float f1 = 0.1F - (float) i * 0.025F - (float) j * 0.01F;
    float f2 = 0.05F + (float) i * 0.01F - (float) j * 0.01F;
    f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
    f2 = MathHelper.clamp_float(f2, 0.0F, 1.0F);

    if (f < f1) {
      this.angler.triggerAchievement(StatList.junkFishedStat);
      return ((WeightedRandomFishable) WeightedRandom.getRandomItem(this.rand, JUNK))
          .getItemStack(this.rand);
    } else {
      f = f - f1;

      if (f < f2) {
        this.angler.triggerAchievement(StatList.treasureFishedStat);
        return ((WeightedRandomFishable) WeightedRandom.getRandomItem(this.rand, TREASURE))
            .getItemStack(this.rand);
      } else {
        float f3 = f - f2;
        this.angler.triggerAchievement(StatList.fishCaughtStat);
        return ((WeightedRandomFishable) WeightedRandom.getRandomItem(this.rand, FISH))
            .getItemStack(this.rand);
      }
    }
  }
示例#2
0
  @Override
  @SideOnly(Side.CLIENT)
  public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
    int l = 0;
    int i1 = 0;
    int j1 = 0;
    int meta = world.getBlockMetadata(x, y, z);

    for (int k1 = -1; k1 <= 1; ++k1) {
      for (int l1 = -1; l1 <= 1; ++l1) {
        BiomeGenBase biome = world.getBiomeGenForCoords(x + l1, z + k1);
        int grassColor = 0;
        if (meta == 1) {
          double temp = (double) MathHelper.clamp_float(biome.getFloatTemperature(), 0.0F, 1.0F);
          double rainfall = (double) MathHelper.clamp_float(biome.getFloatRainfall(), 0.0F, 1.0F);
          grassColor = GrassColorizerAlternate.getBlueGrassColor(temp, rainfall);
        } else if (meta == 2) {
          double temp = (double) MathHelper.clamp_float(biome.getFloatTemperature(), 0.0F, 1.0F);
          double rainfall = (double) MathHelper.clamp_float(biome.getFloatRainfall(), 0.0F, 1.0F);
          grassColor = GrassColorizerAlternate.getOrangeGrassColor(temp, rainfall);
        } else {
          grassColor = biome.getBiomeGrassColor();
        }
        l += (grassColor & 16711680) >> 16;
        i1 += (grassColor & 65280) >> 8;
        j1 += grassColor & 255;
      }
    }
    return (l / 9 & 255) << 16 | (i1 / 9 & 255) << 8 | j1 / 9 & 255;
  }
示例#3
0
  public void func_147068_g() {
    ItemStack var1 = inventorySlots.getSlot(0).getStack();

    if (!ItemStack.areItemStacksEqual(var1, field_147077_B)) {
      field_147077_B = var1;

      do field_147082_x += field_147074_F.nextInt(4) - field_147074_F.nextInt(4);
      while (field_147071_v <= field_147082_x + 1.0F && field_147071_v >= field_147082_x - 1.0F);
    }

    ++field_147073_u;
    field_147069_w = field_147071_v;
    field_147076_A = field_147080_z;
    boolean var2 = false;

    for (int var3 = 0; var3 < 3; ++var3) if (field_147075_G.enchantLevels[var3] != 0) var2 = true;

    if (var2) field_147080_z += 0.2F;
    else field_147080_z -= 0.2F;

    field_147080_z = MathHelper.clamp_float(field_147080_z, 0.0F, 1.0F);
    float var5 = (field_147082_x - field_147071_v) * 0.4F;
    float var4 = 0.2F;
    var5 = MathHelper.clamp_float(var5, -var4, var4);
    field_147081_y += (var5 - field_147081_y) * 0.9F;
    field_147071_v += field_147081_y;
  }
  /** Updates the task */
  @Override
  public void updateTask() {
    double distToTargetSq =
        entityHost.getDistanceSq(
            attackTarget.posX, attackTarget.boundingBox.minY, attackTarget.posZ);
    boolean canSeeTarget = entityHost.getEntitySenses().canSee(attackTarget);

    if (canSeeTarget) {
      ++timeTargetVisible;
    } else {
      timeTargetVisible = 0;
    }

    boolean runningAway = isRunningAway();
    if (!runningAway) {
      runAwayTimer--;
    }

    if (!runningAway && distToTargetSq <= attackRangeSq && timeTargetVisible >= 20) {
      getNavigator().clearPathEntity();
    } else if (distToTargetSq > (attackRangeSq * 0.9)) {
      getNavigator().tryMoveToEntityLiving(attackTarget, getMoveSpeed());
    }

    if (canSeeTarget
        && entityHost.isRiding()
        && distToTargetSq < 36
        && runAwayTimer <= 0
        && runAway()) {
      --timeUntilNextAttack;
      return;
    }

    if (runningAway) {
      --timeUntilNextAttack;
      return;
    }

    entityHost.getLookHelper().setLookPositionWithEntity(attackTarget, 30.0F, 30.0F);

    if (--timeUntilNextAttack == 0) {
      if (distToTargetSq > attackRangeSq || !canSeeTarget) {
        return;
      }
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      rangeRatio = MathHelper.clamp_float(rangeRatio, 0.1f, 1);
      rangedAttackEntityHost.attackEntityWithRangedAttack(attackTarget, rangeRatio);
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    } else if (timeUntilNextAttack < 0) {
      float rangeRatio = MathHelper.sqrt_double(distToTargetSq) / attackRange;
      timeUntilNextAttack =
          MathHelper.floor_float(
              rangeRatio * (maxRangedAttackTime - minRangedAttackTime) + minRangedAttackTime);
    }
  }
示例#5
0
  private void func_180480_a(float p_180480_1_, ScaledResolution p_180480_2_) {
    p_180480_1_ = 1.0F - p_180480_1_;
    p_180480_1_ = MathHelper.clamp_float(p_180480_1_, 0.0F, 1.0F);
    WorldBorder var3 = this.mc.theWorld.getWorldBorder();
    float var4 = (float) var3.getClosestDistance(this.mc.thePlayer);
    double var5 =
        Math.min(
            var3.func_177749_o() * (double) var3.getWarningTime() * 1000.0D,
            Math.abs(var3.getTargetSize() - var3.getDiameter()));
    double var7 = Math.max((double) var3.getWarningDistance(), var5);

    if ((double) var4 < var7) {
      var4 = 1.0F - (float) ((double) var4 / var7);
    } else {
      var4 = 0.0F;
    }

    this.prevVignetteBrightness =
        (float)
            ((double) this.prevVignetteBrightness
                + (double) (p_180480_1_ - this.prevVignetteBrightness) * 0.01D);
    GlStateManager.disableDepth();
    GlStateManager.depthMask(false);
    GlStateManager.tryBlendFuncSeparate(0, 769, 1, 0);

    if (var4 > 0.0F) {
      GlStateManager.color(0.0F, var4, var4, 1.0F);
    } else {
      GlStateManager.color(
          this.prevVignetteBrightness,
          this.prevVignetteBrightness,
          this.prevVignetteBrightness,
          1.0F);
    }

    this.mc.getTextureManager().bindTexture(vignetteTexPath);
    Tessellator var9 = Tessellator.getInstance();
    WorldRenderer var10 = var9.getWorldRenderer();
    var10.startDrawingQuads();
    var10.addVertexWithUV(0.0D, (double) p_180480_2_.getScaledHeight(), -90.0D, 0.0D, 1.0D);
    var10.addVertexWithUV(
        (double) p_180480_2_.getScaledWidth(),
        (double) p_180480_2_.getScaledHeight(),
        -90.0D,
        1.0D,
        1.0D);
    var10.addVertexWithUV((double) p_180480_2_.getScaledWidth(), 0.0D, -90.0D, 1.0D, 0.0D);
    var10.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
    var9.draw();
    GlStateManager.depthMask(true);
    GlStateManager.enableDepth();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  }
  // Thank you to http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
  public float[] getColor() {

    if (color == null) {
      // Define
      float color[] = new float[3];
      float temperature = ((getTemperature() * .477f) + 10f); // 0 -> 10 100 -> 57.7

      // Find red
      if (temperature < 66) color[0] = 1f;
      else {
        color[0] = temperature - 60;
        color[0] = 329.69f * (float) Math.pow(color[0], -0.1332f);

        color[0] = MathHelper.clamp_float(color[0] / 255f, 0f, 1f);
      }

      // Calc Green
      if (temperature < 66) {
        color[1] = temperature;
        color[1] = (float) (99.47f * Math.log(color[1]) - 161.1f);
      } else {
        color[1] = temperature - 60;
        color[1] = 288f * (float) Math.pow(color[1], -0.07551);
      }
      color[1] = MathHelper.clamp_float(color[1] / 255f, 0f, 1f);

      // Calculate Blue
      if (temperature > 67) color[2] = 1f;
      else if (temperature <= 19) {
        color[2] = 0f;
      } else {
        color[2] = temperature - 10;
        color[2] = (float) (138.51f * Math.log(color[2]) - 305.04f);
        color[2] = MathHelper.clamp_float(color[2] / 255f, 0f, 1f);
      }

      this.color = color;
    }
    return color;
  }
示例#7
0
  @Override
  public void doRender(
      EntityPrimedCharge entity,
      double x,
      double y,
      double z,
      float p_76986_8_,
      float partialTicks) {

    BlockRendererDispatcher blockrendererdispatcher =
        Minecraft.getMinecraft().getBlockRendererDispatcher();
    GlStateManager.pushMatrix();
    GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
    float f2;

    if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
      f2 = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
      f2 = MathHelper.clamp_float(f2, 0.0F, 1.0F);
      f2 *= f2;
      f2 *= f2;
      float f3 = 1.0F + f2 * 0.3F;
      GlStateManager.scale(f3, f3, f3);
    }

    f2 = (1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
    this.bindEntityTexture(entity);
    GlStateManager.translate(-0.5F, -0.5F, 0.5F);
    blockrendererdispatcher.renderBlockBrightness(
        entity.getBlock().getDefaultState(), entity.getBrightness(partialTicks));
    GlStateManager.translate(0.0F, 0.0F, 1.0F);

    if (entity.fuse / 5 % 2 == 0) {
      GlStateManager.disableTexture2D();
      GlStateManager.disableLighting();
      GlStateManager.enableBlend();
      GlStateManager.blendFunc(770, 772);
      GlStateManager.color(1.0F, 1.0F, 1.0F, f2);
      GlStateManager.doPolygonOffset(-3.0F, -3.0F);
      GlStateManager.enablePolygonOffset();
      blockrendererdispatcher.renderBlockBrightness(entity.getBlock().getDefaultState(), 1.0F);
      GlStateManager.doPolygonOffset(0.0F, 0.0F);
      GlStateManager.disablePolygonOffset();
      GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
      GlStateManager.disableBlend();
      GlStateManager.enableLighting();
      GlStateManager.enableTexture2D();
    }

    GlStateManager.popMatrix();
    super.doRender(entity, x, y, z, p_76986_8_, partialTicks);
  }
示例#8
0
  @Override
  public int getBrightnessForRender(float p_70070_1_) {
    float f1 = ((float) this.particleAge + p_70070_1_) / (float) this.particleMaxAge;
    f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
    int i = super.getBrightnessForRender(p_70070_1_);
    int j = i & 255;
    int k = i >> 16 & 255;
    j += (int) (f1 * 15.0F * 16.0F);

    if (j > 240) {
      j = 240;
    }

    return j | k << 16;
  }
  private float calculateAdditionalDifficulty(
      EnumDifficulty difficulty, long worldTime, long chunkInhabitedTime, float moonPhaseFactor) {
    if (difficulty == EnumDifficulty.PEACEFUL) {
      return 0.0F;
    } else {
      boolean flag = difficulty == EnumDifficulty.HARD;
      float f1 = 0.75F;
      float f2 =
          MathHelper.clamp_float(((float) worldTime + -72000.0F) / 1440000.0F, 0.0F, 1.0F) * 0.25F;
      f1 += f2;
      float f3 = 0.0F;
      f3 +=
          MathHelper.clamp_float((float) chunkInhabitedTime / 3600000.0F, 0.0F, 1.0F)
              * (flag ? 1.0F : 0.75F);
      f3 += MathHelper.clamp_float(moonPhaseFactor * 0.25F, 0.0F, f2);

      if (difficulty == EnumDifficulty.EASY) {
        f3 *= 0.5F;
      }

      f1 += f3;
      return (float) difficulty.getDifficultyId() * f1;
    }
  }
 /**
  * Spawns the provided ItemStack as an EntityItem with randomized position and motion
  *
  * @param motionFactor EntityItem's motion is multiplied by this amount; clamped between 0.0F and
  *     1.0F
  */
 public static void spawnItemWithRandom(
     World world, ItemStack stack, double x, double y, double z, float motionFactor) {
   if (!world.isRemote && stack != null) {
     double spawnX = x + world.rand.nextFloat();
     double spawnY = y + world.rand.nextFloat();
     double spawnZ = z + world.rand.nextFloat();
     float f = MathHelper.clamp_float(motionFactor, 0.0F, 1.0F);
     EntityItem entityitem = new EntityItem(world, spawnX, spawnY, spawnZ, stack);
     entityitem.motionX = (-0.5F + world.rand.nextGaussian()) * f;
     entityitem.motionY = (4 + world.rand.nextGaussian()) * f;
     entityitem.motionZ = (-0.5F + world.rand.nextGaussian()) * f;
     entityitem.delayBeforeCanPickup = 10;
     world.spawnEntityInWorld(entityitem);
   }
 }
示例#11
0
 public void func_180434_a(
     WorldRenderer p_180434_1_,
     Entity p_180434_2_,
     float p_180434_3_,
     float p_180434_4_,
     float p_180434_5_,
     float p_180434_6_,
     float p_180434_7_,
     float p_180434_8_) {
   float var9 = ((float) this.particleAge + p_180434_3_) / (float) this.particleMaxAge * 32.0F;
   var9 = MathHelper.clamp_float(var9, 0.0F, 1.0F);
   this.particleScale = this.reddustParticleScale * var9;
   super.func_180434_a(
       p_180434_1_,
       p_180434_2_,
       p_180434_3_,
       p_180434_4_,
       p_180434_5_,
       p_180434_6_,
       p_180434_7_,
       p_180434_8_);
 }
示例#12
0
 public int func_180625_c(BlockPos p_180625_1_) {
   double var2 = (double) MathHelper.clamp_float(this.func_180626_a(p_180625_1_), 0.0F, 1.0F);
   double var4 = (double) MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
   return ColorizerFoliage.getFoliageColor(var2, var4);
 }
示例#13
0
 /** takes temperature, returns color */
 public int getSkyColorByTemp(float p_76731_1_) {
   p_76731_1_ /= 3.0F;
   p_76731_1_ = MathHelper.clamp_float(p_76731_1_, -1.0F, 1.0F);
   return Color.getHSBColor(0.62222224F - p_76731_1_ * 0.05F, 0.5F + p_76731_1_ * 0.1F, 1.0F)
       .getRGB();
 }
 public void setHealth(float par1) {
   this.dataWatcher.updateObject(
       6, Float.valueOf(MathHelper.clamp_float(par1, 0.0F, this.getMaxHealth())));
 }
示例#15
0
 /** Gets how bright this entity is. */
 public float getBrightness(float p_70013_1_) {
   float f1 = ((float) this.particleAge + p_70013_1_) / (float) this.particleMaxAge;
   f1 = MathHelper.clamp_float(f1, 0.0F, 1.0F);
   float f2 = super.getBrightness(p_70013_1_);
   return f2 * f1 + (1.0F - f1);
 }
  @Override
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
    EntityGrimReaper reaper = (EntityGrimReaper) entity;

    if (reaper.getAttackState() == EnumReaperAttackState.PRE) {
      this.leftLegPreAttack.render(f5);
      this.leftArmPreAttack.render(f5);
      this.rightLegPreAttack.render(f5);
      this.chestPreAttack.render(f5);
      this.cowlPreAttack.render(f5);
      this.headPreAttack.render(f5);
      this.rightArmPreAttack.render(f5);
      this.scytheHandlePreAttack.render(f5);
      this.scytheHeadPreAttack.render(f5);
    } else if (reaper.getAttackState() == EnumReaperAttackState.POST) {
      this.leftLegPostAttack.render(f5);
      this.leftArmPostAttack.render(f5);
      this.rightLegPostAttack.render(f5);
      this.chestPostAttack.render(f5);
      this.cowlPostAttack.render(f5);
      this.headPostAttack.render(f5);
      this.rightArmPostAttack.render(f5);
      this.scytheHandlePostAttack.render(f5);
      this.scytheHeadPostAttack.render(f5);
    } else if (reaper.getAttackState() == EnumReaperAttackState.BLOCK) {
      this.cowlBlock.render(f5);
      this.leftLegBlock.render(f5);
      this.headBlock.render(f5);
      this.rightArmBlock.render(f5);
      this.scytheHandleBlock.render(f5);
      this.rightLegBlock.render(f5);
      this.chestBlock.render(f5);
      this.leftArmBlock.render(f5);
      this.scytheHeadBlock.render(f5);
    } else if (reaper.getAttackState() == EnumReaperAttackState.REST) {

      GL11.glPushMatrix();
      {
        double amt = Math.cos(reaper.getFloatingTicks()) / 4;
        GL11.glTranslated(0.0D, amt, 0.0D);

        this.rightArmRest.render(f5);
        this.rightLegRest.render(f5);
        this.leftArmRest.render(f5);
        this.chestRest.render(f5);
        this.leftLegRest.render(f5);
        this.cowlRest.render(f5);

        GL11.glPushMatrix();
        {
          double amt2 = Math.cos(reaper.getFloatingTicks()) / 8;
          GL11.glTranslated(0.0D, amt2, 0.0D);

          this.scytheHeadRest.render(f5);
          this.scytheHandleRest.render(f5);
        }
        GL11.glPopMatrix();
      }
      GL11.glPopMatrix();
    } else {
      rightLeg.rotateAngleX =
          MathHelper.clamp_float(
              MathHelper.cos(100F * 0.6662F + 3.141593F) * 2.5F * f1, 0.0F, 1.1F);
      leftLeg.rotateAngleX =
          MathHelper.clamp_float(
              MathHelper.cos(100F * 0.6662F + 3.141593F) * 2.5F * f1, 0.0F, 1.1F);
      rightLeg.rotateAngleX =
          MathHelper.clamp_float(
              MathHelper.cos(100F * 0.6662F + 3.141593F) * 2.5F * f1, 0.0F, 1.1F);
      leftLeg.rotateAngleX =
          MathHelper.clamp_float(
              MathHelper.cos(100F * 0.6662F + 3.141593F) * 2.5F * f1, 0.0F, 1.1F);

      rightLeg.rotateAngleY = 0.0F;
      leftLeg.rotateAngleY = 0.0F;

      this.leftLeg.render(f5);
      this.leftArm.render(f5);
      this.rightLeg.render(f5);
      this.chest.render(f5);
      this.cowl.render(f5);
      this.head.render(f5);
      this.rightArm.render(f5);
    }
  }
  @Override
  public boolean attackEntityFrom(DamageSource src, float dmg) {
    if (src.isProjectile() || this.worldObj.isRemote) return false;

    if (src.getEntity() instanceof EntityLivingBase) {
      EntityLivingBase entity = (EntityLivingBase) src.getEntity();
      boolean flag =
          TragicConfig.getBoolean("allowDivinity") && entity.isPotionActive(TragicPotion.Divinity);

      if (rand.nextInt(4) == 0
          && this.getAttackTarget() != entity
          && entity.getCreatureAttribute() != TragicEntities.Synapse) this.setAttackTarget(entity);

      if (flag && this.hurtResistantTime == 0
          || !TragicConfig.getBoolean("allowDivinity")
              && entity.getCreatureAttribute() != TragicEntities.Synapse
              && this.hurtResistantTime == 0
          || entity.getHeldItem() != null
              && entity.getHeldItem().getItem() == TragicItems.SwordOfJustice
          || src.canHarmInCreative()
          || !TragicConfig.getBoolean("overlordDivineWeakness")
          || !TragicConfig.getBoolean("overlordPhases")) {
        this.phaseDamage +=
            MathHelper.clamp_float(
                dmg - this.getTotalArmorValue(), 0F, (float) TragicConfig.getInt("bossDamageCap"));

        if (this.getCurrentPhase() < 4) {
          float f = this.getMaxHealth() / 5;
          switch (this.getCurrentPhase()) {
            case 0:
              f *= 4;
              break;
            case 1:
              f *= 3;
              break;
            case 2:
              f *= 2;
              break;
            case 3:
              break;
            case 4:
              f = 0;
              break;
            default:
              break;
          }

          if (this.getHealth()
                          - MathHelper.clamp_float(
                              dmg - this.getTotalArmorValue(),
                              0F,
                              (float) TragicConfig.getInt("bossDamageCap"))
                      <= f
                  && f > 0
              || this.phaseDamage >= this.getMaxHealth() / 5) {
            this.phaseChange = true;
            dmg = 0;
            this.phaseDamage = 0F;
          }
        }

        if (rand.nextBoolean()
            && this.worldObj
                    .getEntitiesWithinAABB(
                        EntityNanoSwarm.class,
                        this.getEntityBoundingBox().expand(64.0, 64.0, 64.0D))
                    .size()
                < 16
            && this.getCurrentPhase() > 1
            && TragicConfig.getBoolean("allowNanoSwarm")
            && TragicConfig.getBoolean("overlordNanoSwarms")) {
          EntityNanoSwarm swarm = new EntityNanoSwarm(this.worldObj);
          swarm.setPosition(
              this.posX + rand.nextInt(6) - rand.nextInt(6),
              this.posY,
              this.posZ + rand.nextInt(6) - rand.nextInt(6));
          this.worldObj.spawnEntityInWorld(swarm);
        }

        return super.attackEntityFrom(src, dmg);
      }
    }
    return true;
  }