public static void onAttackEntityFrom(DamageSource damage, EntityLiving living) {
    if (living.getHealth() > 0 && living.hurtTime <= 0) {
      float f = 0.41F;

      if (living.canBleed() && living.canBleedByDamage(damage)) {
        Entity entity = damage.getEntity();

        if (GoreRegistry.containsFarDamage(damage.damageType)) {
          produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
        } else if (entity instanceof EntityPlayer) {
          ItemStack is = ((EntityPlayer) entity).getCurrentEquippedItem();

          if (living.canHurtByItem(is)) {
            f = 1.0F;
            living.isBleeding = true;
            living.ticksActuallyBleeding = 0;
            living.ticksNoBlood = 0;
            produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
          }
        } else {
          produceBlood(MathHelper.floor_double(GoreRegistry.AMOUT_PARTICLES * f), false, living);
        }
      }
    }
  }
Exemple #2
0
 public static float[] getRotationsNeeded(Entity entity) {
   if (entity == null) return null;
   double diffX = entity.posX - Minecraft.getMinecraft().thePlayer.posX;
   double diffY;
   if (entity instanceof EntityLivingBase) {
     EntityLivingBase entityLivingBase = (EntityLivingBase) entity;
     diffY =
         entityLivingBase.posY
             + entityLivingBase.getEyeHeight() * 0.9
             - (Minecraft.getMinecraft().thePlayer.posY
                 + Minecraft.getMinecraft().thePlayer.getEyeHeight());
   } else
     diffY =
         (entity.boundingBox.minY + entity.boundingBox.maxY) / 2.0D
             - (Minecraft.getMinecraft().thePlayer.posY
                 + Minecraft.getMinecraft().thePlayer.getEyeHeight());
   double diffZ = entity.posZ - Minecraft.getMinecraft().thePlayer.posZ;
   double dist = MathHelper.sqrt_double(diffX * diffX + diffZ * diffZ);
   float yaw = (float) (Math.atan2(diffZ, diffX) * 180.0D / Math.PI) - 90.0F;
   float pitch = (float) -(Math.atan2(diffY, dist) * 180.0D / Math.PI);
   return new float[] {
     Minecraft.getMinecraft().thePlayer.rotationYaw
         + MathHelper.wrapAngleTo180_float(yaw - Minecraft.getMinecraft().thePlayer.rotationYaw),
     Minecraft.getMinecraft().thePlayer.rotationPitch
         + MathHelper.wrapAngleTo180_float(
             pitch - Minecraft.getMinecraft().thePlayer.rotationPitch)
   };
 }
Exemple #3
0
  /** Updates the JList with a new model. */
  public void update() {
    MusicTicker.MusicType var1 = this.mc.getAmbientMusicType();

    if (this.currentMusic != null) {
      if (!var1.getMusicLocation().equals(this.currentMusic.getSoundLocation())) {
        this.mc.getSoundHandler().stopSound(this.currentMusic);
        this.timeUntilNextMusic =
            MathHelper.getRandomIntegerInRange(this.rand, 0, var1.getMinDelay() / 2);
      }

      if (!this.mc.getSoundHandler().isSoundPlaying(this.currentMusic)) {
        this.currentMusic = null;
        this.timeUntilNextMusic =
            Math.min(
                MathHelper.getRandomIntegerInRange(
                    this.rand, var1.getMinDelay(), var1.getMaxDelay()),
                this.timeUntilNextMusic);
      }
    }

    if (this.currentMusic == null && this.timeUntilNextMusic-- <= 0) {
      this.currentMusic =
          PositionedSoundRecord.createPositionedSoundRecord(var1.getMusicLocation());
      this.mc.getSoundHandler().playSound(this.currentMusic);
      this.timeUntilNextMusic = Integer.MAX_VALUE;
    }
  }
 MovingObjectPosition rayTrace(World world, EntityLivingBase entity, boolean adjacent) {
   float f1 = entity.rotationPitch;
   float f2 = entity.rotationYaw;
   double y = entity.posY + entity.getEyeHeight() - entity.yOffset;
   Vec3 vec3 = Vec3.createVectorHelper(entity.posX, y, entity.posZ);
   float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
   float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
   float f5 = -MathHelper.cos(-f1 * 0.017453292F);
   float f6 = MathHelper.sin(-f1 * 0.017453292F);
   float f7 = f4 * f5;
   float f8 = f3 * f5;
   double d3 = 5.0D;
   if (entity instanceof EntityPlayerMP) {
     d3 = ((EntityPlayerMP) entity).theItemInWorldManager.getBlockReachDistance();
   }
   Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
   MovingObjectPosition ret = world.func_147447_a(vec3, vec31, adjacent, !adjacent, false);
   if (ret != null && adjacent) {
     ForgeDirection side = ForgeDirection.getOrientation(ret.sideHit);
     ret.blockX += side.offsetX;
     ret.blockY += side.offsetY;
     ret.blockZ += side.offsetZ;
   }
   return ret;
 }
  public static MovingObjectPosition getMovingObjectPositionFromPlayer(
      World world, EntityLivingBase living, boolean bool) {
    float f = 1.0F;
    float f1 = living.prevRotationPitch + (living.rotationPitch - living.prevRotationPitch) * f;
    float f2 = living.prevRotationYaw + (living.rotationYaw - living.prevRotationYaw) * f;
    double d0 = living.prevPosX + (living.posX - living.prevPosX) * (double) f;
    double d1 =
        living.prevPosY
            + (living.posY - living.prevPosY) * (double) f
            + (double)
                (world.isRemote
                    ? living.getEyeHeight()
                        - (living instanceof EntityPlayer
                            ? ((EntityPlayer) living).getDefaultEyeHeight()
                            : 0)
                    : living
                        .getEyeHeight()); // isRemote check to revert changes to ray trace position
    // due to adding the eye height clientside and player
    // yOffset differences
    double d2 = living.prevPosZ + (living.posZ - living.prevPosZ) * (double) f;
    Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
    float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;
    double d3 = 5.0D;
    if (living instanceof EntityPlayerMP)
      d3 = ((EntityPlayerMP) living).theItemInWorldManager.getBlockReachDistance();

    Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
    return world.func_147447_a(vec3, vec31, bool, !bool, false);
  }
  private void checkNearbyBlocks(SSEntityScriptedSurvivor ess) {
    int i = MathHelper.floor_double(ess.posX);
    int j = MathHelper.floor_double(ess.boundingBox.minY);
    int k = MathHelper.floor_double(ess.posZ);
    boolean flag = true;
    if (isTargetBlock(ess, i, j - 1, k)) {
      j--;
    } else if (isTargetBlock(ess, i, j + 2, k)) {
      j += 2;
    } else if (isTargetBlock(ess, i - 1, j, k)) {
      i--;
    } else if (isTargetBlock(ess, i, j, k - 1)) {
      k--;
    } else if (isTargetBlock(ess, i + 1, j, k)) {
      i++;
    } else if (isTargetBlock(ess, i, j, k + 1)) {
      k++;
    } else flag = false;

    if (flag) {
      ess.coords = new int[3];
      ess.coords[0] = i;
      ess.coords[1] = j;
      ess.coords[2] = k;
      ess.path = ess.worldObj.getEntityPathToXYZ(ess, i, j, k, 12F);
    }
  }
Exemple #7
0
 public void setRotationAngles(
     float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
   HEADBASE.rotateAngleY = f3 / (270F / (float) Math.PI);
   HEADBASE.rotateAngleX = f4 / (270F / (float) Math.PI);
   LEFTLEG.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
   RIGHTLEG.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1;
 }
  @Override
  protected void onCrafting(ItemStack par1ItemStack) {
    par1ItemStack.onCrafting(thePlayer.worldObj, thePlayer, stackSize);

    if (!thePlayer.worldObj.isRemote) {
      int i = stackSize;
      float f = MaterializerRecipes.instance().getExperience(par1ItemStack);
      int j;

      if (f == 0.0F) i = 0;
      else if (f < 1.0F) {
        j = MathHelper.floor_float(i * f);

        if (j < MathHelper.ceiling_float_int(i * f) && (float) Math.random() < i * f - j) ++j;

        i = j;
      }

      while (i > 0) {
        j = EntityXPOrb.getXPSplit(i);
        i -= j;
        thePlayer.worldObj.spawnEntityInWorld(
            new EntityXPOrb(
                thePlayer.worldObj,
                thePlayer.posX,
                thePlayer.posY + 0.5D,
                thePlayer.posZ + 0.5D,
                j));
      }
    }

    stackSize = 0;

    MinecraftForge.EVENT_BUS.post(new ACEvents.ItemMaterializedEvent(thePlayer, par1ItemStack));
  }
  public static Fluid getFluid(EntityItem item, boolean below) {
    double d0 = item.posY + (double) item.getEyeHeight();
    int i = MathHelper.floor_double(item.posX);
    int j = MathHelper.floor_float((float) MathHelper.floor_double(d0));
    if (below) j--;
    int k = MathHelper.floor_double(item.posZ);
    Block block = item.worldObj.getBlock(i, j, k);

    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
    if (fluid == null && block instanceof IFluidBlock) fluid = ((IFluidBlock) block).getFluid();
    else if (block instanceof BlockLiquid) fluid = FluidRegistry.WATER;

    if (below) return fluid;

    double filled = 1.0f; // If it's not a liquid assume it's a solid block
    if (block instanceof IFluidBlock) {
      filled = ((IFluidBlock) block).getFilledPercentage(item.worldObj, i, j, k);
    }

    if (filled < 0) {
      filled *= -1;
      // filled -= 0.11111111F; //Why this is needed.. not sure...
      if (d0 > (double) (j + (1 - filled))) return fluid;
    } else {
      if (d0 < (double) (j + filled)) return fluid;
    }
    return null;
  }
        @Override
        /**
         * Updates the task
         */
        public void updateTask()
        {
            Random random = this.field_179473_a.getRNG();
            World world = this.field_179473_a.worldObj;
            int i = MathHelper.floor_double(this.field_179473_a.posX - 2.0D + random.nextDouble() * 4.0D);
            int j = MathHelper.floor_double(this.field_179473_a.posY + random.nextDouble() * 3.0D);
            int k = MathHelper.floor_double(this.field_179473_a.posZ - 2.0D + random.nextDouble() * 4.0D);
            BlockPos blockpos = new BlockPos(i, j, k);
            IBlockState iblockstate = world.getBlockState(blockpos);
            Block block = iblockstate.getBlock();

            if (EntityChaoticEnderman.carriableBlocks.contains(block))
            {
            	int blockMeta = ModBlocks.chaos_Block.getMetaFromState(iblockstate);
            	if (block != ModBlocks.chaos_Block || (blockMeta < 4)) {
            		this.field_179473_a.func_175490_a(iblockstate);
            		world.setBlockState(blockpos, Blocks.air.getDefaultState());
            	} else
            		this.field_179473_a.func_175490_a(ModBlocks.chaos_Block.getStateFromMeta((world.rand.nextFloat() >= 0.2F ?
            			13 : 14) + blockMeta < 2 ? 0 : 1));
            }
        }
Exemple #11
0
  public static MovingObjectPosition getMovingObjectPositionFromPlayer(
      World par1World, EntityPlayer par2EntityPlayer, boolean par3) {
    float var4 = 1.0F;
    float var5 =
        par2EntityPlayer.prevRotationPitch
            + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
    float var6 =
        par2EntityPlayer.prevRotationYaw
            + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
    double var7 =
        par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
    double var9 =
        par2EntityPlayer.prevPosY
            + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4
            + 1.62D
            - par2EntityPlayer.yOffset;
    double var11 =
        par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
    Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
    float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
    float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
    float var16 = -MathHelper.cos(-var5 * 0.017453292F);
    float var17 = MathHelper.sin(-var5 * 0.017453292F);
    float var18 = var15 * var16;
    float var20 = var14 * var16;
    double var21 = 5.0D;

    if (par2EntityPlayer instanceof EntityPlayerMP) {
      var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
    }

    Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
    return par1World.rayTraceBlocks(var13, var23, par3);
  }
 public void setThrowableHeading(double par1, double par3, double par5, float par7, float par8) {
   float f2 = MathHelper.sqrt_double(par1 * par1 + par3 * par3 + par5 * par5);
   par1 /= (double) f2;
   par3 /= (double) f2;
   par5 /= (double) f2;
   par1 +=
       this.rand.nextGaussian()
           * (double) (this.rand.nextBoolean() ? -1 : 1)
           * 0.007499999832361937D
           * (double) par8;
   par3 +=
       this.rand.nextGaussian()
           * (double) (this.rand.nextBoolean() ? -1 : 1)
           * 0.007499999832361937D
           * (double) par8;
   par5 +=
       this.rand.nextGaussian()
           * (double) (this.rand.nextBoolean() ? -1 : 1)
           * 0.007499999832361937D
           * (double) par8;
   par1 *= (double) par7;
   par3 *= (double) par7;
   par5 *= (double) par7;
   this.motionX = par1;
   this.motionY = par3;
   this.motionZ = par5;
   float f3 = MathHelper.sqrt_double(par1 * par1 + par5 * par5);
   this.prevRotationYaw = this.rotationYaw = (float) (Math.atan2(par1, par5) * 180.0D / Math.PI);
   this.prevRotationPitch =
       this.rotationPitch = (float) (Math.atan2(par3, (double) f3) * 180.0D / Math.PI);
   this.ticksInGround = 0;
 }
Exemple #13
0
 @Override
 public void setRotationAngles(
     float f, float f1, float f2, float f3, float f4, float f5, Entity e) {
   super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
   if ((e instanceof EntityBunny && ((EntityBunny) e).isSitting())) {
     Body.rotateAngleX = 0.95993f;
     Leg1.rotateAngleX = Leg2.rotateAngleX = -1.5708f;
     Leg3.rotateAngleX = Leg4.rotateAngleX = -0.2818f;
     Leg1.rotationPointY = Leg2.rotationPointY = 23;
     Leg1.rotationPointZ = Leg2.rotationPointZ = 2;
   } else {
     Leg1.rotationPointY = Leg2.rotationPointY = 19;
     Leg1.rotationPointZ = Leg2.rotationPointZ = 3;
     this.Body.rotateAngleX = ((float) Math.PI / 2F);
     this.Leg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
     this.Leg2.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1;
     this.Leg3.rotateAngleX = MathHelper.cos(f * 0.6662F + (float) Math.PI) * 1.4F * f1;
     this.Leg4.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1;
   }
   this.Head.rotateAngleX = f4 / (180F / (float) Math.PI);
   this.Head.rotateAngleY = f3 / (180F / (float) Math.PI);
   this.Ear1.rotateAngleX = f4 / (180F / (float) Math.PI);
   this.Ear1.rotateAngleY = f3 / (180F / (float) Math.PI);
   this.Ear2.rotateAngleX = f4 / (180F / (float) Math.PI);
   this.Ear2.rotateAngleY = f3 / (180F / (float) Math.PI);
   this.tail.rotateAngleX = ((float) Math.PI / 2F);
 }
  public TickTaskFillSquare(WorldServer world) {
    this.isComplete = false;
    this.world = world;
    this.X =
        this.minX =
            ModuleWorldBorder.borderData.getInteger("minX") - ModuleWorldBorder.overGenerate;
    this.Z =
        this.minZ =
            ModuleWorldBorder.borderData.getInteger("minZ") - ModuleWorldBorder.overGenerate;
    this.maxX = ModuleWorldBorder.borderData.getInteger("maxX") + ModuleWorldBorder.overGenerate;
    this.maxZ = ModuleWorldBorder.borderData.getInteger("maxZ") + ModuleWorldBorder.overGenerate;
    this.centerX = ModuleWorldBorder.borderData.getInteger("centerX");
    this.centerZ = ModuleWorldBorder.borderData.getInteger("centerZ");
    this.rad = ModuleWorldBorder.borderData.getInteger("rad");

    this.eta =
        (int)
            (((MathHelper.abs_int((this.maxX - this.minX) / 16)
                * MathHelper.abs_int((this.minZ - this.maxZ) / 16))));

    warnEveryone(Localization.get(Localization.WB_FILL_START));
    warnEveryone(FEChatFormatCodes.AQUA + "minX:" + this.minX + "  maxX:" + this.maxX);
    warnEveryone(FEChatFormatCodes.AQUA + "minZ:" + this.minZ + "  maxZ:" + this.maxZ);

    warnEveryone(Localization.get(Localization.WB_FILL_ETA).replaceAll("%eta", getETA()));
  }
 public S11PacketSpawnExperienceOrb(EntityXPOrb p_i45167_1_) {
   this.field_148992_a = p_i45167_1_.getEntityId();
   this.field_148990_b = MathHelper.floor_double(p_i45167_1_.posX * 32.0D);
   this.field_148991_c = MathHelper.floor_double(p_i45167_1_.posY * 32.0D);
   this.field_148988_d = MathHelper.floor_double(p_i45167_1_.posZ * 32.0D);
   this.field_148989_e = p_i45167_1_.getXpValue();
 }
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    if (this.worldObj.isDaytime() && !this.worldObj.isRemote) {
      float f = this.getBrightness(1.0F);

      if (f > 0.5F
          && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F
          && this.worldObj.canBlockSeeSky(
              new BlockPos(
                  MathHelper.floor_double(this.posX),
                  MathHelper.floor_double(this.posY),
                  MathHelper.floor_double(this.posZ)))) {
        boolean flag = true;
        ItemStack itemstack = this.getEquipmentInSlot(4);

        if (itemstack != null) {
          if (itemstack.isItemStackDamageable()) {
            itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));

            if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) {
              this.renderBrokenItemStack(itemstack);
              this.setCurrentItemOrArmor(4, (ItemStack) null);
            }
          }

          flag = false;
        }
      }
    }

    super.onLivingUpdate();
  }
Exemple #17
0
  /**
   * Called frequently so the entity can update its state every tick as required. For example,
   * zombies and skeletons use this to react to sunlight and start to burn.
   */
  public void onLivingUpdate() {
    super.onLivingUpdate();

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

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

    if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D
        && this.rand.nextInt(5) == 0) {
      int i = MathHelper.floor_double(this.posX);
      int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
      int k = MathHelper.floor_double(this.posZ);
      IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(i, j, k));
      Block block = iblockstate.getBlock();

      if (block.getMaterial() != Material.air) {
        this.worldObj.spawnParticle(
            EnumParticleTypes.BLOCK_CRACK,
            this.posX + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            this.getEntityBoundingBox().minY + 0.1D,
            this.posZ + ((double) this.rand.nextFloat() - 0.5D) * (double) this.width,
            4.0D * ((double) this.rand.nextFloat() - 0.5D),
            0.5D,
            ((double) this.rand.nextFloat() - 0.5D) * 4.0D,
            new int[] {Block.getStateId(iblockstate)});
      }
    }
  }
  public void func_75649_a() {
    this.field_75659_a.field_70125_A = 0.0F;
    if (this.field_75655_d) {
      this.field_75655_d = false;
      double var1 = this.field_75656_e - this.field_75659_a.field_70165_t;
      double var3 =
          this.field_75653_f
              - (this.field_75659_a.field_70163_u + (double) this.field_75659_a.func_70047_e());
      double var5 = this.field_75654_g - this.field_75659_a.field_70161_v;
      double var7 = (double) MathHelper.func_76133_a(var1 * var1 + var5 * var5);
      float var9 = (float) (Math.atan2(var5, var1) * 180.0D / 3.1415927410125732D) - 90.0F;
      float var10 = (float) (-(Math.atan2(var3, var7) * 180.0D / 3.1415927410125732D));
      this.field_75659_a.field_70125_A =
          this.func_75652_a(this.field_75659_a.field_70125_A, var10, this.field_75658_c);
      this.field_75659_a.field_70759_as =
          this.func_75652_a(this.field_75659_a.field_70759_as, var9, this.field_75657_b);
    } else {
      this.field_75659_a.field_70759_as =
          this.func_75652_a(
              this.field_75659_a.field_70759_as, this.field_75659_a.field_70761_aq, 10.0F);
    }

    float var11 =
        MathHelper.func_76142_g(
            this.field_75659_a.field_70759_as - this.field_75659_a.field_70761_aq);
    if (!this.field_75659_a.func_70661_as().func_75500_f()) {
      if (var11 < -75.0F) {
        this.field_75659_a.field_70759_as = this.field_75659_a.field_70761_aq - 75.0F;
      }

      if (var11 > 75.0F) {
        this.field_75659_a.field_70759_as = this.field_75659_a.field_70761_aq + 75.0F;
      }
    }
  }
  private void setNewWayPoint(SSEntityScriptedSurvivor ess) {
    boolean flag = false;
    int j = -1;
    int k = -1;
    int l = -1;
    float f2 = -99999F;
    ess.coords = null;
    for (int i1 = 0; i1 < 10; i1++) {
      int j1 = MathHelper.floor_double((ess.posX + (double) ess.getRNG().nextInt(21)) - 10D);
      int k1 = MathHelper.floor_double((ess.posY + (double) ess.getRNG().nextInt(7)) - 3D);
      int l1 = MathHelper.floor_double((ess.posZ + (double) ess.getRNG().nextInt(21)) - 10D);
      float f3 = isTargetBlock(ess, j1, k1, l1) ? 1000F : (float) ess.getDistance(j1, k1, l1);
      if (f3 == 1000F) {
        j = j1;
        k = k1;
        l = l1;
        ess.coords = new int[3];
        ess.coords[0] = j;
        ess.coords[1] = k;
        ess.coords[2] = l;
        flag = true;
        break;
      } else if (f3 > f2) {
        f2 = f3;
        j = j1;
        k = k1;
        l = l1;
        flag = true;
      }
    }

    if (flag) {
      ess.path = ess.worldObj.getEntityPathToXYZ(ess, j, k, l, 18F);
    }
  }
  /**
   * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the
   * movement of arms and legs, where par1 represents the time(so that arms and legs swing back and
   * forth) and par2 represents how "far" arms and legs can swing at most.
   */
  public void setRotationAngles(
      float p_78087_1_,
      float p_78087_2_,
      float p_78087_3_,
      float p_78087_4_,
      float p_78087_5_,
      float p_78087_6_,
      Entity p_78087_7_) {
    for (int i = 0; i < this.silverfishBodyParts.length; ++i) {
      this.silverfishBodyParts[i].rotateAngleY =
          MathHelper.cos(p_78087_3_ * 0.9F + (float) i * 0.15F * (float) Math.PI)
              * (float) Math.PI
              * 0.05F
              * (float) (1 + Math.abs(i - 2));
      this.silverfishBodyParts[i].rotationPointX =
          MathHelper.sin(p_78087_3_ * 0.9F + (float) i * 0.15F * (float) Math.PI)
              * (float) Math.PI
              * 0.2F
              * (float) Math.abs(i - 2);
    }

    this.silverfishWings[0].rotateAngleY = this.silverfishBodyParts[2].rotateAngleY;
    this.silverfishWings[1].rotateAngleY = this.silverfishBodyParts[4].rotateAngleY;
    this.silverfishWings[1].rotationPointX = this.silverfishBodyParts[4].rotationPointX;
    this.silverfishWings[2].rotateAngleY = this.silverfishBodyParts[1].rotateAngleY;
    this.silverfishWings[2].rotationPointX = this.silverfishBodyParts[1].rotationPointX;
  }
Exemple #21
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;
  }
Exemple #22
0
  /** Updates look */
  public void onUpdateLook() {
    this.entity.rotationPitch = 0.0F;

    if (this.isLooking) {
      this.isLooking = false;
      double var1 = this.posX - this.entity.posX;
      double var3 = this.posY - (this.entity.posY + (double) this.entity.getEyeHeight());
      double var5 = this.posZ - this.entity.posZ;
      double var7 = (double) MathHelper.sqrt_double(var1 * var1 + var5 * var5);
      float var9 = (float) (Math.atan2(var5, var1) * 180.0D / Math.PI) - 90.0F;
      float var10 = (float) (-(Math.atan2(var3, var7) * 180.0D / Math.PI));
      this.entity.rotationPitch =
          this.updateRotation(this.entity.rotationPitch, var10, this.deltaLookPitch);
      this.entity.rotationYawHead =
          this.updateRotation(this.entity.rotationYawHead, var9, this.deltaLookYaw);
    } else {
      this.entity.rotationYawHead =
          this.updateRotation(this.entity.rotationYawHead, this.entity.renderYawOffset, 10.0F);
    }

    float var11 =
        MathHelper.wrapAngleTo180_float(this.entity.rotationYawHead - this.entity.renderYawOffset);

    if (!this.entity.getNavigator().noPath()) {
      if (var11 < -75.0F) {
        this.entity.rotationYawHead = this.entity.renderYawOffset - 75.0F;
      }

      if (var11 > 75.0F) {
        this.entity.rotationYawHead = this.entity.renderYawOffset + 75.0F;
      }
    }
  }
  public void doStitch() {
    Stitcher.Holder[] aholder =
        (Stitcher.Holder[])
            this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]);
    Arrays.sort(aholder);
    Stitcher.Holder[] aholder1 = aholder;
    int i = aholder.length;

    for (int j = 0; j < i; ++j) {
      Stitcher.Holder holder = aholder1[j];

      if (!this.allocateSlot(holder)) {
        String s =
            String.format(
                "Unable to fit: %s - size: %dx%d - Maybe try a lowerresolution texturepack?",
                new Object[] {
                  holder.getAtlasSprite().getIconName(),
                  Integer.valueOf(holder.getAtlasSprite().getIconWidth()),
                  Integer.valueOf(holder.getAtlasSprite().getIconHeight())
                });
        throw new StitcherException(holder, s);
      }
    }

    if (this.forcePowerOf2) {
      this.currentWidth = MathHelper.roundUpToPowerOfTwo(this.currentWidth);
      this.currentHeight = MathHelper.roundUpToPowerOfTwo(this.currentHeight);
    }
  }
 /** the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */
 protected void onCrafting(ItemStack par1ItemStack) {
   par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b);
   if (!this.thePlayer.worldObj.isRemote) {
     int var2 = this.field_75228_b;
     float var3 = RecipesCoffeeGrinder.smelting().getExperience(par1ItemStack.itemID);
     int var4;
     if (var3 == 0.0F) {
       var2 = 0;
     } else if (var3 < 1.0F) {
       var4 = MathHelper.floor_float((float) var2 * var3);
       if (var4 < MathHelper.ceiling_float_int((float) var2 * var3)
           && (float) Math.random() < (float) var2 * var3 - (float) var4) {
         ++var4;
       }
       var2 = var4;
     }
     while (var2 > 0) {
       var4 = EntityXPOrb.getXPSplit(var2);
       var2 -= var4;
       this.thePlayer.worldObj.spawnEntityInWorld(
           new EntityXPOrb(
               this.thePlayer.worldObj,
               this.thePlayer.posX,
               this.thePlayer.posY + 0.5D,
               this.thePlayer.posZ + 0.5D,
               var4));
     }
   }
   this.field_75228_b = 0;
 }
 /** Drops the entity's currently held item into the world */
 public static void dropHeldItem(EntityLivingBase entity) {
   if (!entity.worldObj.isRemote && entity.getHeldItem() != null) {
     EntityItem drop =
         new EntityItem(
             entity.worldObj,
             entity.posX,
             entity.posY - 0.30000001192092896D + (double) entity.getEyeHeight(),
             entity.posZ,
             entity.getHeldItem().copy());
     float f = 0.3F;
     float f1 = entity.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F;
     drop.motionX =
         (double)
             (-MathHelper.sin(entity.rotationYaw / 180.0F * (float) Math.PI)
                 * MathHelper.cos(entity.rotationPitch / 180.0F * (float) Math.PI)
                 * f);
     drop.motionZ =
         (double)
             (MathHelper.cos(entity.rotationYaw / 180.0F * (float) Math.PI)
                 * MathHelper.cos(entity.rotationPitch / 180.0F * (float) Math.PI)
                 * f);
     drop.motionY =
         (double) (-MathHelper.sin(entity.rotationPitch / 180.0F * (float) Math.PI) * f + 0.1F);
     f = 0.02F * entity.worldObj.rand.nextFloat();
     drop.motionX += Math.cos((double) f1) * (double) f;
     drop.motionY +=
         (double) ((entity.worldObj.rand.nextFloat() - entity.worldObj.rand.nextFloat()) * 0.1F);
     drop.motionZ += Math.sin((double) f1) * (double) f;
     drop.delayBeforeCanPickup = 40;
     entity.worldObj.spawnEntityInWorld(drop);
     entity.setCurrentItemOrArmor(0, (ItemStack) null);
   }
 }
Exemple #26
0
  /** Gets the safe pathing Y position for the entity depending on if it can path swim or not */
  private int getPathableYPos() {
    if (this.theEntity.isInWater() && this.canSwim) {
      int var1 = (int) this.theEntity.boundingBox.minY;
      int var2 =
          this.worldObj.getBlockId(
              MathHelper.floor_double(this.theEntity.posX),
              var1,
              MathHelper.floor_double(this.theEntity.posZ));
      int var3 = 0;

      do {
        if (var2 != Block.waterMoving.blockID && var2 != Block.waterStill.blockID) {
          return var1;
        }

        ++var1;
        var2 =
            this.worldObj.getBlockId(
                MathHelper.floor_double(this.theEntity.posX),
                var1,
                MathHelper.floor_double(this.theEntity.posZ));
        ++var3;
      } while (var3 <= 16);

      return (int) this.theEntity.boundingBox.minY;
    } else {
      return (int) (this.theEntity.boundingBox.minY + 0.5D);
    }
  }
  /** Called when the mob is falling. Calculates and applies fall damage. */
  protected void fall(float distance) {
    if (distance > 1.0F) {
      this.playSound("mob.horse.land", 0.4F, 1.0F);
    }

    int i = MathHelper.ceiling_float_int(distance * 0.5F - 3.0F);

    if (i > 0) {
      this.attackEntityFrom(DamageSource.fall, (float) i);

      if (this.riddenByEntity != null) {
        this.riddenByEntity.attackEntityFrom(DamageSource.fall, (float) i);
      }

      Block block =
          this.worldObj.getBlock(
              MathHelper.floor_double(this.posX),
              MathHelper.floor_double(this.posY - 0.2D - (double) this.prevRotationYaw),
              MathHelper.floor_double(this.posZ));

      if (block.getMaterial() != Material.air) {
        Block.SoundType soundtype = block.stepSound;
        this.worldObj.playSoundAtEntity(
            this,
            soundtype.getStepSound(),
            soundtype.getVolume() * 0.5F,
            soundtype.getFrequency() * 0.75F);
      }
    }
  }
  public static ArrayList<StructureVillagePieceWeightDeimos> getStructureVillageWeightedPieceList(
      Random par0Random, int par1) {
    final ArrayList<StructureVillagePieceWeightDeimos> var2 =
        new ArrayList<StructureVillagePieceWeightDeimos>();
    var2.add(
        new StructureVillagePieceWeightDeimos(
            StructureComponentDeimosVillageWoodHut.class,
            5,
            MathHelper.getRandomIntegerInRange(par0Random, 2 + par1, 5 + par1 * 3)));
    var2.add(
        new StructureVillagePieceWeightDeimos(
            StructureComponentDeimosVillageField.class,
            5,
            MathHelper.getRandomIntegerInRange(par0Random, 3 + par1, 5 + par1)));
    var2.add(
        new StructureVillagePieceWeightDeimos(
            StructureComponentDeimosVillageHouse.class,
            5,
            MathHelper.getRandomIntegerInRange(par0Random, 3 + par1, 4 + par1 * 2)));

    final Iterator<StructureVillagePieceWeightDeimos> var3 = var2.iterator();

    while (var3.hasNext()) {
      if (var3.next().villagePiecesLimit == 0) {
        var3.remove();
      }
    }

    return var2;
  }
 /** Sets the listener of sounds */
 public void setListener(EntityLivingBase par1EntityLivingBase, float par2) {
   if (this.loaded && this.options.soundVolume != 0.0F && par1EntityLivingBase != null) {
     float f1 =
         par1EntityLivingBase.prevRotationPitch
             + (par1EntityLivingBase.rotationPitch - par1EntityLivingBase.prevRotationPitch)
                 * par2;
     float f2 =
         par1EntityLivingBase.prevRotationYaw
             + (par1EntityLivingBase.rotationYaw - par1EntityLivingBase.prevRotationYaw) * par2;
     double d0 =
         par1EntityLivingBase.prevPosX
             + (par1EntityLivingBase.posX - par1EntityLivingBase.prevPosX) * (double) par2;
     double d1 =
         par1EntityLivingBase.prevPosY
             + (par1EntityLivingBase.posY - par1EntityLivingBase.prevPosY) * (double) par2;
     double d2 =
         par1EntityLivingBase.prevPosZ
             + (par1EntityLivingBase.posZ - par1EntityLivingBase.prevPosZ) * (double) par2;
     float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI);
     float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI);
     float f5 = -f4;
     float f6 = -MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI);
     float f7 = -f3;
     float f8 = 0.0F;
     float f9 = 1.0F;
     float f10 = 0.0F;
     this.sndSystem.setListenerPosition((float) d0, (float) d1, (float) d2);
     this.sndSystem.setListenerOrientation(f5, f6, f7, f8, f9, f10);
   }
 }
  /** 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;
    }
  }