public static boolean testOreBlock(int testOreID, BlockPos testPos, IBlockAccess worldObj) {
    IBlockState _blockState = worldObj.getBlockState(testPos);
    Block _block = _blockState.getBlock();
    int metaData = _block.getMetaFromState(_blockState);

    ItemStack testItem = new ItemStack(Item.getItemFromBlock(_block), 1, metaData);
    return testOre(testOreID, testItem);
  }
  @SubscribeEvent
  public void onUpdate(LivingUpdateEvent event) {
    EntityLivingBase base = event.entityLiving;

    if (base instanceof EntityPlayer) {
      EntityPlayer sp = (EntityPlayer) base;
      if (sp.capabilities.isCreativeMode) return;
    }

    World world = base.worldObj;

    double x = base.posX;
    double y = base.posY;
    double z = base.posZ;

    if (GenerationUtils.getBiomeGenForCoords(world, base.getPosition(), UBiome.infestedBiomBase)) {
      addPotion(base, 0);
    }

    double range = 3;

    double xRange = range;
    double yRange = range;
    double zRange = range;

    for (double xPos = x - xRange; xPos <= x + xRange; xPos++) {
      for (double yPos = y - yRange; yPos <= y + yRange; yPos++) {
        for (double zPos = z - zRange; zPos <= z + zRange; zPos++) {
          if (world.isRemote) continue;
          BlockPos pos = new BlockPos(xPos, yPos, zPos);
          IBlockState blockcks = world.getBlockState(pos);
          Block block = blockcks.getBlock();
          if (!GenerationUtils.getBiomeGenForCoords(world, pos, UBiome.infestedBiomBase)) {
            if (block == UBlocks.ores) {
              EnumTypeBaseStuff type =
                  EnumTypeBaseStuff.byMetadata(block.getMetaFromState(blockcks));
              if (type.getName() == "uran") {
                if (new Random().nextInt(50) == 0) {
                  addPotion(base, 1);
                }
              }
            } else if (block instanceof IInfectedBlock) {
              if (new Random().nextInt(200) == 0) {
                addPotion(base, 0);
              }
            }
          }
          continue;
        }
      }
    }
  }
  public static ItemStack createItemStack(IBlockState state, int amount) {

    Block block = state.getBlock();
    Item item = Item.getItemFromBlock(block);

    if (null != item) {

      int meta = item.getHasSubtypes() ? block.getMetaFromState(state) : 0;

      return new ItemStack(item, amount, meta);
    }

    return null;
  }
Exemple #4
0
  /* Tests a block to see if it can be mined with the current equipment
   * Returns 0 if it can't, -1 if it is cobble
   * Will return 2 if mined with pick, 3 if shovel, 1 if none
   * return 4 if just need to fill using the filler upgrade  */
  public int canMineBlock(int x, int y, int z) {
    BlockPos minePos = new BlockPos(x, y, z);
    IBlockState tryState = worldObj.getBlockState(minePos);
    Block tryBlock = tryState.getBlock();

    if (tryBlock != null) {
      int meta = tryBlock.getMetaFromState(tryState);
      if ((tryBlock.getBlockHardness(tryState, worldObj, minePos) >= 0)
          && (!tryBlock.isAir(tryState, worldObj, minePos))) {
        boolean mine = false;
        // ProgressiveAutomation.logger.info("Tool: "+tryBlock.getHarvestTool(meta)+", Level:
        // "+tryBlock.getHarvestLevel(meta)+", Can use Pick: "+tryBlock.isToolEffective("pickaxe",
        // meta));
        // ProgressiveAutomation.logger.info("Harvestable:
        // "+ForgeHooks.canToolHarvestBlock(tryBlock, meta, getStackInSlot(2)));
        if (tryBlock == Blocks.COBBLESTONE) {
          return -1;
        }
        if (tryBlock.getHarvestTool(tryState) == "chisel") { // this is compatibility for chisel 1
          return 2;
        } else if (tryBlock.getHarvestTool(tryState) == "pickaxe") {
          if (ForgeHooks.canToolHarvestBlock(worldObj, minePos, getStackInSlot(2))) {
            // ProgressiveAutomation.logger.info("Tool can harvest");
            return 2;
          }
        } else if (tryBlock.getHarvestTool(tryState) == "shovel") {
          if (ForgeHooks.canToolHarvestBlock(worldObj, minePos, getStackInSlot(3))) {
            return 3;
          }
        } else {
          if (!tryBlock.getMaterial(tryState).isLiquid()) {
            return 1;
          }
        }
      }

      // see if the filler upgrade is active, if it is then the block will need to be filled.
      if (hasUpgrade(UpgradeType.FILLER)) {
        if ((tryBlock.isAir(tryState, worldObj, minePos))
            || (tryBlock.getMaterial(tryState).isLiquid())) {
          return 4;
        }
      }
    }
    return 0;
  }
  private int registerBlock(Block block, String name, int idHint) {
    // handle ItemBlock-before-Block registrations
    ItemBlock itemBlock = null;

    for (Item item : iItemRegistry.typeSafeIterable()) // find matching ItemBlock
    {
      if (item instanceof ItemBlock && ((ItemBlock) item).block == block) {
        itemBlock = (ItemBlock) item;
        break;
      }
    }

    if (itemBlock
        != null) // has ItemBlock, adjust id and clear the slot already occupied by the
                 // corresponding item
    {
      idHint = iItemRegistry.getId(itemBlock);
      FMLLog.fine("Found matching ItemBlock %s for Block %s at id %d", itemBlock, block, idHint);
      freeSlot(
          idHint,
          block); // temporarily free the slot occupied by the Item for the block registration
    }

    // add
    int blockId = iBlockRegistry.add(idHint, name, block, availabilityMap);

    if (itemBlock != null) // verify
    {
      if (blockId != idHint)
        throw new IllegalStateException(
            String.format(
                "Block at itemblock id %d insertion failed, got id %d.", idHint, blockId));
      verifyItemBlockName(itemBlock);
    }

    useSlot(blockId);
    ((RegistryDelegate.Delegate<Block>) block.delegate).setName(name);

    for (IBlockState state : ((List<IBlockState>) block.getBlockState().getValidStates())) {
      GameData.BLOCKSTATE_TO_ID.put(state, blockId << 4 | block.getMetaFromState(state));
    }

    return blockId;
  }
 @Override
 public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) {
   BlockPos pos = mop.getBlockPos();
   IBlockState state = world.getBlockState(pos);
   Block b = state.getBlock();
   int meta = b.getMetaFromState(state);
   if (meta == 8 && b == GCBlocks.basicBlock) {
     return new ItemStack(GCBlocks.basicBlock, 1, 8);
   }
   if (meta == 2 && b == GCBlocks.blockMoon) {
     return new ItemStack(GCBlocks.blockMoon, 1, 2);
   }
   if (b == GCBlocks.fakeBlock && meta == 1) {
     return new ItemStack(GCBlocks.spaceStationBase, 1, 0);
   }
   if (b == GCBlocks.fakeBlock && meta == 2) {
     return new ItemStack(GCBlocks.landingPad, 1, 0);
   }
   if (b == GCBlocks.fakeBlock && meta == 6) {
     return new ItemStack(GCBlocks.landingPad, 1, 1);
   }
   return null;
 }
 public static ItemStack getItemStack(IBlockState state, int amount) {
   final Block block = state.getBlock();
   return new ItemStack(block, amount, block.getMetaFromState(state));
 }
Exemple #8
0
  public void mine() {
    if ((slots[1] == null) || (slots[2] == null) || (slots[3] == null)) return;
    if (currentBlock != null) {
      // continue to mine this block
      if (miningTime <= 0) {
        miningTime = 0;
        // clock is done, lets mine it
        Point2I currentPoint = spiral(currentColumn, pos.getX(), pos.getZ());
        BlockPos currentPosition =
            new BlockPos(currentPoint.getX(), currentYLevel, currentPoint.getY());
        // ProgressiveAutomation.logger.info("Point: "+miningWith+"
        // "+currentPoint.getX()+","+currentYLevel+","+currentPoint.getY());

        // don't harvest anything if the block is air or liquid
        if (miningWith != 4) {
          // get the inventory of anything under it
          if (worldObj.getTileEntity(currentPosition) instanceof IInventory) {
            IInventory inv = (IInventory) worldObj.getTileEntity(currentPosition);
            for (int i = 0; i < inv.getSizeInventory(); i++) {
              if (inv.getStackInSlot(i) != null) {
                addToInventory(inv.getStackInSlot(i));
                inv.setInventorySlotContents(i, null);
              }
            }
          }

          // silk touch the block if we have it
          int silkTouch = 0;
          if (miningWith != 1) {
            silkTouch =
                EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, slots[miningWith]);
          }

          if (silkTouch > 0) {
            int i = 0;
            Item item = Item.getItemFromBlock(currentBlock);
            if (item != null && item.getHasSubtypes())
              i = currentBlock.getMetaFromState(worldObj.getBlockState(currentPosition));

            ItemStack addItem = new ItemStack(currentBlock, 1, i);
            addToInventory(addItem);

          } else {
            // mine the block
            int fortuneLevel = 0;
            if (miningWith != 1) {
              fortuneLevel =
                  EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, slots[miningWith]);
            }

            // then break the block
            List<ItemStack> items =
                currentBlock.getDrops(
                    worldObj,
                    currentPosition,
                    worldObj.getBlockState(currentPosition),
                    fortuneLevel);
            // get the drops
            for (ItemStack item : items) {
              addToInventory(item);
            }
          }

          if (miningWith != 1) {
            if (ToolHelper.damageTool(
                slots[miningWith],
                worldObj,
                currentPoint.getX(),
                currentYLevel,
                currentPoint.getY())) {
              destroyTool(miningWith);
            }
          }
        }

        // remove the block and entity if there is one
        worldObj.removeTileEntity(currentPosition);
        worldObj.setBlockState(currentPosition, Blocks.COBBLESTONE.getDefaultState());
        slots[1].stackSize--;
        if (slots[1].stackSize == 0) {
          slots[1] = null;
        }
        currentMineBlocks++;
        addPartialUpdate("MinedBlocks", currentMineBlocks);
        currentBlock = null;

      } else {
        miningTime--;
      }
    } else {
      if (!isDone()) {
        currentBlock = getNextBlock();
        if (currentBlock != null) {
          Point2I currentPoint = spiral(currentColumn, pos.getX(), pos.getZ());
          BlockPos currentPosition =
              new BlockPos(currentPoint.getX(), currentYLevel, currentPoint.getY());
          IBlockState currentBlockState = worldObj.getBlockState(currentPosition);

          if (miningWith == 4) {
            miningTime = 1;
          } else {
            miningTime =
                (int)
                    Math.ceil(
                        currentBlock.getBlockHardness(currentBlockState, worldObj, currentPosition)
                            * 1.5
                            * 20);

            if (miningWith != 1) {
              float miningSpeed = ToolHelper.getDigSpeed(slots[miningWith], currentBlockState);

              // check for efficiency on the tool
              if (miningSpeed > 1) {
                int eff =
                    EnchantmentHelper.getEnchantmentLevel(
                        Enchantments.EFFICIENCY, slots[miningWith]);
                if (eff > 0) {
                  for (int i = 0; i < eff; i++) {
                    miningSpeed = miningSpeed * 1.3f;
                  }
                }
              }

              miningTime = (int) Math.ceil(miningTime / miningSpeed);
            }
          }

          // ProgressiveAutomation.logger.info("Mining: "+currentBlock.getUnlocalizedName()+" in
          // "+miningTime+" ticks");

        }
      }
    }

    if (isDone()) {
      // ProgressiveAutomation.logger.info("Done Update");
      scanBlocks();
      currentColumn = getRange();
    }
  }
  @Override
  public void rebuildChunk(
      final float x, final float y, final float z, final ChunkCompileTaskGenerator generator) {
    final CompiledOverlay compiledOverlay = new CompiledOverlay();
    final BlockPos from = getPosition();
    final BlockPos to = from.add(15, 15, 15);
    generator.getLock().lock();
    RegionRenderCache regionRenderCache;
    final SchematicWorld schematic = (SchematicWorld) this.world;

    try {
      if (generator.getStatus() != ChunkCompileTaskGenerator.Status.COMPILING) {
        return;
      }

      if (from.getX() < 0
          || from.getZ() < 0
          || from.getX() >= schematic.getWidth()
          || from.getZ() >= schematic.getLength()) {
        generator.setCompiledChunk(CompiledChunk.DUMMY);
        return;
      }

      regionRenderCache =
          new RegionRenderCache(this.world, from.add(-1, -1, -1), to.add(1, 1, 1), 1);
      generator.setCompiledChunk(compiledOverlay);
    } finally {
      generator.getLock().unlock();
    }

    final VisGraph visgraph = new VisGraph();

    if (!regionRenderCache.extendedLevelsInChunkCache()) {
      ++renderChunksUpdated;

      final World mcWorld = Minecraft.getMinecraft().theWorld;

      final EnumWorldBlockLayer layer = EnumWorldBlockLayer.TRANSLUCENT;
      final WorldRenderer worldRenderer =
          generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(layer);

      GeometryTessellator.setStaticDelta(ConfigurationHandler.blockDelta);

      for (final BlockPos pos : BlockPos.getAllInBox(from, to)) {
        if (schematic.isRenderingLayer && schematic.renderingLayer != pos.getY()
            || !schematic.isInside(pos)) {
          continue;
        }

        boolean render = false;
        int sides = 0;
        int color = 0;

        final IBlockState schBlockState = schematic.getBlockState(pos);
        final Block schBlock = schBlockState.getBlock();

        if (schBlock.isOpaqueCube()) {
          visgraph.func_178606_a(pos);
        }

        final BlockPos mcPos = pos.add(schematic.position);
        final IBlockState mcBlockState = mcWorld.getBlockState(mcPos);
        final Block mcBlock = mcBlockState.getBlock();

        final boolean isSchAirBlock = schematic.isAirBlock(pos);
        final boolean isMcAirBlock =
            mcWorld.isAirBlock(mcPos) || ConfigurationHandler.isExtraAirBlock(mcBlock);

        if (!isMcAirBlock) {
          if (isSchAirBlock && ConfigurationHandler.highlightAir) {
            render = true;
            sides = GeometryMasks.Quad.ALL;
            color = 0xBF00BF;
          }
        }

        if (!render) {
          if (ConfigurationHandler.highlight) {
            if (!isMcAirBlock) {
              if (schBlock != mcBlock) {
                render = true;
                color = 0xFF0000;
              } else if (schBlock.getMetaFromState(schBlockState)
                  != mcBlock.getMetaFromState(mcBlockState)) {
                render = true;
                color = 0xBF5F00;
              }
            } else if (!isSchAirBlock) {
              render = true;
              color = 0x00BFFF;
            }
          }

          if (render) {
            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.DOWN), EnumFacing.DOWN)) {
              sides |= GeometryMasks.Quad.DOWN;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.UP), EnumFacing.UP)) {
              sides |= GeometryMasks.Quad.UP;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.NORTH), EnumFacing.NORTH)) {
              sides |= GeometryMasks.Quad.NORTH;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.SOUTH), EnumFacing.SOUTH)) {
              sides |= GeometryMasks.Quad.SOUTH;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.WEST), EnumFacing.WEST)) {
              sides |= GeometryMasks.Quad.WEST;
            }

            if (schBlock.shouldSideBeRendered(
                schematic, pos.offset(EnumFacing.EAST), EnumFacing.EAST)) {
              sides |= GeometryMasks.Quad.EAST;
            }
          }
        }

        if (render && sides != 0) {
          if (!compiledOverlay.isLayerStarted(layer)) {
            compiledOverlay.setLayerStarted(layer);
            preRenderBlocks(worldRenderer, from);
          }

          GeometryTessellator.drawCuboid(worldRenderer, pos, sides, 0x3F000000 | color);
          compiledOverlay.setLayerUsed(layer);
        }
      }

      if (compiledOverlay.isLayerStarted(layer)) {
        postRenderBlocks(layer, x, y, z, worldRenderer, compiledOverlay);
      }
    }

    compiledOverlay.setVisibility(visgraph.computeVisibility());
  }
 @Override
 public LocalMaterialData withDefaultBlockData() {
   Block block = blockData.getBlock();
   return this.withBlockData(block.getMetaFromState(block.getDefaultState()));
 }
  @Override
  @SuppressWarnings("unchecked")
  public void onUpdate() {
    super.onUpdate();

    if (this.ticksExisted > 400) {
      if (this.isHot) {
        this.isHot = false;
        this.setHot(this.isHot);
      }
    } else if (!this.worldObj.isRemote) {
      this.setHot(this.isHot);
    }

    if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
      float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
      this.prevRotationYaw =
          this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
      this.prevRotationPitch =
          this.rotationPitch = (float) (Math.atan2(this.motionY, f) * 180.0D / Math.PI);
    }

    BlockPos pos = new BlockPos(this.xTile, this.yTile, this.zTile);
    Block block = this.worldObj.getBlockState(pos).getBlock();

    if (!block.isAir(this.worldObj, pos)) {
      block.setBlockBoundsBasedOnState(this.worldObj, pos);
      AxisAlignedBB axisalignedbb =
          block.getCollisionBoundingBox(this.worldObj, pos, this.worldObj.getBlockState(pos));

      if (axisalignedbb != null
          && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) {
        this.inGround = true;
      }
    }

    if (this.inGround) {
      Block j = this.worldObj.getBlockState(pos).getBlock();
      int k = j.getMetaFromState(this.worldObj.getBlockState(pos));

      if (j == this.inTile && k == this.inData) {
        ++this.ticksInGround;

        if (this.ticksInGround == 1200) {
          this.setDead();
        }
      } else {
        this.inGround = false;
        this.motionX *= this.rand.nextFloat() * 0.2F;
        this.motionY *= this.rand.nextFloat() * 0.2F;
        this.motionZ *= this.rand.nextFloat() * 0.2F;
        this.ticksInGround = 0;
        this.ticksInAir = 0;
      }
    } else {
      ++this.ticksInAir;
      Vec3 vec3 = new Vec3(this.posX, this.posY, this.posZ);
      Vec3 vec31 =
          new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition =
          this.worldObj.rayTraceBlocks(vec3, vec31, false, true, false);
      vec3 = new Vec3(this.posX, this.posY, this.posZ);
      vec31 =
          new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

      if (movingobjectposition != null) {
        vec31 =
            new Vec3(
                movingobjectposition.hitVec.xCoord,
                movingobjectposition.hitVec.yCoord,
                movingobjectposition.hitVec.zCoord);
      }

      this.rotationPitch += 1F;

      Entity entity = null;
      List<Entity> list =
          this.worldObj.getEntitiesWithinAABBExcludingEntity(
              this,
              this.getEntityBoundingBox()
                  .addCoord(this.motionX, this.motionY, this.motionZ)
                  .expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      int l;
      float f1;

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

        if (entity1.canBeCollidedWith()
            && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) {
          f1 = 0.3F;
          AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand(f1, f1, f1);
          MovingObjectPosition movingobjectposition1 =
              axisalignedbb1.calculateIntercept(vec3, vec31);

          if (movingobjectposition1 != null) {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

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

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

      if (movingobjectposition != null
          && movingobjectposition.entityHit != null
          && movingobjectposition.entityHit instanceof EntityPlayer) {
        EntityPlayer entityplayer = (EntityPlayer) movingobjectposition.entityHit;

        if (entityplayer.capabilities.disableDamage
            || this.shootingEntity instanceof EntityPlayer
                && !((EntityPlayer) this.shootingEntity).canAttackPlayer(entityplayer)) {
          movingobjectposition = null;
        }
      }

      float f2;
      float f3;
      double damage = ConfigManagerCore.hardMode ? 3.2D : 1.6D;

      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null) {
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          int i1 = MathHelper.ceiling_double_int(f2 * damage);

          DamageSource damagesource = null;

          if (this.shootingEntity == null) {
            damagesource =
                new EntityDamageSourceIndirect("meteorChunk", this, this).setProjectile();
          } else {
            damagesource =
                new EntityDamageSourceIndirect("meteorChunk", this, this.shootingEntity)
                    .setProjectile();
          }

          if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) {
            movingobjectposition.entityHit.setFire(2);
          }

          if (movingobjectposition.entityHit.attackEntityFrom(damagesource, i1)) {
            if (movingobjectposition.entityHit instanceof EntityLivingBase) {
              EntityLivingBase entitylivingbase = (EntityLivingBase) movingobjectposition.entityHit;

              if (!this.worldObj.isRemote) {
                entitylivingbase.setArrowCountInEntity(
                    entitylivingbase.getArrowCountInEntity() + 1);
              }

              if (this.knockbackStrength > 0) {
                f3 =
                    MathHelper.sqrt_double(
                        this.motionX * this.motionX + this.motionZ * this.motionZ);

                if (f3 > 0.0F) {
                  movingobjectposition.entityHit.addVelocity(
                      this.motionX * this.knockbackStrength * 0.6000000238418579D / f3,
                      0.1D,
                      this.motionZ * this.knockbackStrength * 0.6000000238418579D / f3);
                }
              }

              if (this.shootingEntity != null) {
                EnchantmentHelper.applyThornEnchantments(entitylivingbase, this.shootingEntity);
                EnchantmentHelper.applyArthropodEnchantments(
                    (EntityLivingBase) this.shootingEntity, entitylivingbase);
              }

              if (this.shootingEntity != null
                  && movingobjectposition.entityHit != this.shootingEntity
                  && movingobjectposition.entityHit instanceof EntityPlayer
                  && this.shootingEntity instanceof EntityPlayerMP) {
                ((EntityPlayerMP) this.shootingEntity)
                    .playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
              }
            }

            if (!(movingobjectposition.entityHit instanceof EntityEnderman)) {
              this.setDead();
            }
          } else {
            this.motionX *= -0.10000000149011612D;
            this.motionY *= -0.10000000149011612D;
            this.motionZ *= -0.10000000149011612D;
            this.rotationYaw += 180.0F;
            this.prevRotationYaw += 180.0F;
            this.ticksInAir = 0;
          }
        } else {
          this.xTile = movingobjectposition.getBlockPos().getX();
          this.yTile = movingobjectposition.getBlockPos().getY();
          this.zTile = movingobjectposition.getBlockPos().getZ();
          IBlockState state = this.worldObj.getBlockState(movingobjectposition.getBlockPos());
          this.inTile = state.getBlock();
          this.inData = this.inTile.getMetaFromState(state);
          this.motionX = (float) (movingobjectposition.hitVec.xCoord - this.posX);
          this.motionY = (float) (movingobjectposition.hitVec.yCoord - this.posY);
          this.motionZ = (float) (movingobjectposition.hitVec.zCoord - this.posZ);
          f2 =
              MathHelper.sqrt_double(
                  this.motionX * this.motionX
                      + this.motionY * this.motionY
                      + this.motionZ * this.motionZ);
          this.posX -= this.motionX / f2 * 0.05000000074505806D;
          this.posY -= this.motionY / f2 * 0.05000000074505806D;
          this.posZ -= this.motionZ / f2 * 0.05000000074505806D;
          this.inGround = true;

          if (!this.inTile.isAir(this.worldObj, movingobjectposition.getBlockPos())) {
            this.inTile.onEntityCollidedWithBlock(
                this.worldObj, movingobjectposition.getBlockPos(), this);
          }
        }
      }

      this.posX += this.motionX;
      this.posY += this.motionY;
      this.posZ += this.motionZ;
      f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);

      if (!this.onGround) {
        this.rotationPitch += 10;
        this.rotationYaw += 2;
      }

      float f4 = 0.99F;
      f1 = 0.05F;

      if (this.isInWater()) {
        for (int j1 = 0; j1 < 4; ++j1) {
          f3 = 0.25F;
          this.worldObj.spawnParticle(
              EnumParticleTypes.WATER_BUBBLE,
              this.posX - this.motionX * f3,
              this.posY - this.motionY * f3,
              this.posZ - this.motionZ * f3,
              this.motionX,
              this.motionY,
              this.motionZ);
        }

        f4 = 0.8F;
      }

      this.motionX *= f4;
      this.motionY *= f4;
      this.motionZ *= f4;
      this.motionY -= WorldUtil.getGravityForEntity(this);
      this.setPosition(this.posX, this.posY, this.posZ);
      this.doBlockCollisions();
    }
  }