Package net.minecraft.src

Examples of net.minecraft.src.MovingObjectPosition


    * @param distance - The maximum distance to check
    * @return A coordinate object containing the block that was inline with
    *         the players view
    */
   public Coordinate trace(double distance) {
      MovingObjectPosition m = rayTrace(distance, 1.0F);
      if (m == null) {
         return null;
      }
      return new Coordinate(m.blockX, m.blockY, m.blockZ);
   }
View Full Code Here


        {
            ticksInAir++;
        }
        Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
        Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
        MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3d, vec3d1);
        vec3d = Vec3D.createVector(posX, posY, posZ);
        vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
        if(movingobjectposition != null)
        {
            vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
        }
        Entity entity = null;
        List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
        double d = 0.0D;
        for(int j = 0; j < list.size(); j++)
        {
            Entity entity1 = (Entity)list.get(j);
            if(!entity1.canBeCollidedWith() || entity1.isEntityEqual(shootingEntity) && ticksInAir < 25)
            {
                continue;
            }
            float f2 = 0.3F;
            AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f2, f2, f2);
            MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
            if(movingobjectposition1 == null)
            {
                continue;
            }
            double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
            if(d1 < d || d == 0.0D)
            {
                entity = entity1;
                d = d1;
            }
        }

        if(entity != null)
        {
            movingobjectposition = new MovingObjectPosition(entity);
        }
        if(movingobjectposition != null)
        {
            func_40071_a(movingobjectposition);
        }
View Full Code Here

      return;
    }
    ticksInAir++;
    Vec3D vec3d = Vec3D.createVector(posX, posY, posZ);
    Vec3D vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks_do_do(vec3d, vec3d1,
        false, true);
    vec3d = Vec3D.createVector(posX, posY, posZ);
    vec3d1 = Vec3D.createVector(posX + motionX, posY + motionY, posZ + motionZ);
    if (movingobjectposition != null) {
      vec3d1 = Vec3D.createVector(movingobjectposition.hitVec.xCoord,
          movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
    }
    Entity entity = null;
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(this,
        boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
    double d = 0.0D;
    for (int l = 0; l < list.size(); l++) {
      Entity entity1 = (Entity) list.get(l);
      if (!entity1.canBeCollidedWith() || entity1 == shootingEntity && ticksInAir < 5) {
        continue;
      }
      float f5 = 0.3F;
      AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f5, f5, f5);
      MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3d,
          vec3d1);
      if (movingobjectposition1 == null) {
        continue;
      }
      double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
      if (d1 < d || d == 0.0D) {
        entity = entity1;
        d = d1;
      }
    }

    if (entity != null) {
      movingobjectposition = new MovingObjectPosition(entity);
    }
    if (movingobjectposition != null) {
      if (movingobjectposition.entityHit != null) {
        float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ
            * motionZ);
 
View Full Code Here

        double d = ep.prevPosX + (ep.posX - ep.prevPosX) * (double) f;
        double d1 = (ep.prevPosY + (ep.posY - ep.prevPosY) * (double) f + 1.62D)
            - (double) ep.yOffset;
        double d2 = ep.prevPosZ + (ep.posZ - ep.prevPosZ) * (double) f;
        boolean flag = false;
        MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(
            world, ep, flag);

        if (movingobjectposition == null)
          return itemstack;
        if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) {
View Full Code Here

TOP

Related Classes of net.minecraft.src.MovingObjectPosition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.