Examples of MovingObjectPosition


Examples of net.minecraft.util.MovingObjectPosition

  public static RaytraceResult getClosestHit(Vec3 origin, Collection<RaytraceResult> candidates) {
    double minLengthSquared = Double.POSITIVE_INFINITY;
    RaytraceResult closest = null;

    for (RaytraceResult candidate : candidates) {
      MovingObjectPosition hit = candidate.movingObjectPosition;
      if(hit != null) {
        double lengthSquared = hit.hitVec.squareDistanceTo(origin);
        if(lengthSquared < minLengthSquared) {
          minLengthSquared = lengthSquared;
          closest = candidate;
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

        {
            ++this.ticksInAir;
            Vec3 vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
            Vec3 vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
            // TODO 1.7 May need to call overload with extra params
            MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31, false);
            vec3 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
            vec31 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

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

            Entity entity = null;
            List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.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 = (Entity) list.get(l);

                if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
                {
                    f1 = 0.3F;
                    AxisAlignedBB axisalignedbb1 = entity1.boundingBox.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;
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

    }
   
    ++this.ticksInAir;
    Vec3 pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
    Vec3 nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
    MovingObjectPosition hit = this.worldObj.rayTraceBlocks_do_do(pos, nextPos, false, true);
    pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
    nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
   
    if(hit != null)
    {
      nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(hit.hitVec.xCoord, hit.hitVec.yCoord,  hit.hitVec.zCoord);
    }
   
    Entity entityHit = null;
    List<?> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this,  this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
    double closestRange = 0.0D;
    double collisionRange = 0.3D;
   
    for(int l = 0; l < list.size(); ++l)
    {
      Entity e = (Entity)list.get(l);
     
      if(e.canBeCollidedWith() && (e != _owner || this.ticksInAir >= 5))
      {
        AxisAlignedBB entitybb = e.boundingBox.expand(collisionRange, collisionRange, collisionRange);
        MovingObjectPosition entityHitPos = entitybb.calculateIntercept(pos, nextPos);
       
        if(entityHitPos != null)
        {
          double range = pos.distanceTo(entityHitPos.hitVec);
         
          if(range < closestRange || closestRange == 0.0D)
          {
            entityHit = e;
            closestRange = range;
          }
        }
      }
    }
   
    if(entityHit != null)
    {
      hit = new MovingObjectPosition(entityHit);
    }
   
    if(hit != null && hit.entityHit != null && hit.entityHit instanceof EntityPlayer)
    {
      EntityPlayer entityplayer = (EntityPlayer)hit.entityHit;
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

   
    if(!worldObj.isRemote)
    {
      Vec3 pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      Vec3 nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition hit = this.worldObj.rayTraceBlocks_do_do(pos, nextPos, false, true);
      pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
     
      if(hit != null)
      {
        nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(hit.hitVec.xCoord, hit.hitVec.yCoord,  hit.hitVec.zCoord);
      }
     
      Entity entityHit = null;
      List<?> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this,  this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
      double closestRange = 0.0D;
      double collisionRange = 0.3D;
     
      for(int i = 0, end = list.size(); i < end; ++i)
      {
        Entity e = (Entity)list.get(i);
       
        if(e.canBeCollidedWith() && (e != _owner))
        {
          AxisAlignedBB entitybb = e.boundingBox.expand(collisionRange, collisionRange, collisionRange);
          MovingObjectPosition entityHitPos = entitybb.calculateIntercept(pos, nextPos);
         
          if(entityHitPos != null)
          {
            double range = pos.distanceTo(entityHitPos.hitVec);
           
            if((range < closestRange) | closestRange == 0D)
            {
              entityHit = e;
              closestRange = range;
            }
          }
        }
      }
     
      if(entityHit != null)
      {
        hit = new MovingObjectPosition(entityHit);
      }
     
      if(hit != null && hit.entityHit != null && hit.entityHit instanceof EntityPlayer)
      {
        EntityPlayer entityplayer = (EntityPlayer)hit.entityHit;
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

      AxisAlignedBB part = wireparts[i];
      if(part == null)
      {
        continue;
      }
      MovingObjectPosition hit = part.calculateIntercept(playerPosition, playerViewOffset);
      if(hit != null)
      {
        double distance = playerPosition.distanceTo(hit.hitVec);
        if(distance < closestdistance)
        {
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

  @Override
  public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player)
  {
    if(!world.isRemote)
    {
      MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
      if(mop != null && mop.typeOfHit == EnumMovingObjectType.TILE)
      {
        int blockId = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
        if(MFRRegistry.getLiquidDrinkHandlers().containsKey(blockId))
        {
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

 
 
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
  {
    MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
    if(mop != null && mop.typeOfHit == EnumMovingObjectType.TILE)
    {
      if(MFRRegistry.getLiquidDrinkHandlers().containsKey(world.getBlockId(mop.blockX, mop.blockY, mop.blockZ)))
      {
        player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
  {
   
    if(world.isRemote)
    {
      MovingObjectPosition mop = player.rayTrace(MFRConfig.spyglassRange.getInt(), 1.0F);
      if(mop == null || (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit == null))
      {
        player.sendChatToPlayer("Nothing in sight");
      }
      else if(mop.typeOfHit == EnumMovingObjectType.ENTITY)
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

     
      if(entity.canBeCollidedWith())
      {
        double entitySize = entity.getCollisionBorderSize();
        AxisAlignedBB axisalignedbb = entity.boundingBox.expand(entitySize, entitySize, entitySize);
        MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(playerPos, playerLookRel);
       
        if(axisalignedbb.isVecInside(playerPos))
        {
          if(0.0D < entityDistTotal || entityDistTotal == 0.0D)
          {
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
  {
    if(world.isRemote)
    {
      MovingObjectPosition mop = rayTrace();
      if(mop == null || (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit == null))
      {
        player.sendChatToPlayer("Nothing in sight");
      }
      else if(mop.typeOfHit == EnumMovingObjectType.ENTITY)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.