Package net.minecraft.util

Examples of net.minecraft.util.Vec3


      EntityPlayer entityPlayer) {
    List<RaytraceResult> allHits = doRayTraceAll(world, x, y, z, entityPlayer);
    if(allHits == null) {
      return null;
    }
    Vec3 origin = Util.getEyePosition(entityPlayer);
    return RaytraceResult.getClosestHit(origin, allHits);
  }
View Full Code Here


    double dirY = -Math.sin(pitch);
    double dirZ = Math.cos(yaw) * Math.cos(pitch);

    double reachDistance = EnderIO.proxy.getReachDistanceForPlayer(entityPlayer);

    Vec3 origin = Util.getEyePosition(entityPlayer);
    Vec3 direction = origin.addVector(dirX * reachDistance, dirY *
        reachDistance, dirZ * reachDistance);
    return doRayTraceAll(world, x, y, z, origin, direction,
        entityPlayer);
  }
View Full Code Here

            }
        }
        else
        {
            ++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);
View Full Code Here

      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);
    }
   
    ++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)
View Full Code Here

      }
    }
   
    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;
       
        if(entityplayer.capabilities.disableDamage || (_owner instanceof EntityPlayer && !((EntityPlayer)_owner).func_96122_a(entityplayer)))
        {
          hit = null;
        }
      }
     
      if(hit != null && !worldObj.isRemote)
      {
        if(hit.entityHit != null)
        { // why not spawn explosion at nextPos x/y/z?
          worldObj.newExplosion(this, hit.entityHit.posX, hit.entityHit.posY, hit.entityHit.posZ, 4.0F, true, true);
        }
        else
        {
          worldObj.newExplosion(this, hit.blockX, hit.blockY, hit.blockZ, 4.0F, true, true);
        }
        setDead();
      }
    }
   
    if(_target != null)
    {
      // At this point, I suspect literally no one on this project actually understands what this does or how it works
     
      Vec3 targetVector = worldObj.getWorldVec3Pool().getVecFromPool(_target.posX - posX, _target.posY - posY, _target.posZ - posZ);
      float targetYaw = clampAngle(360 - (float)(Math.atan2(targetVector.xCoord, targetVector.zCoord) * 180.0D / Math.PI), 360, false);
      float targetPitch = clampAngle(-(float)(Math.atan2(targetVector.yCoord, Math.sqrt(targetVector.xCoord * targetVector.xCoord + targetVector.zCoord * targetVector.zCoord)) * 180.0D / Math.PI), 360, false);
     
      float yawDifference = clampAngle(targetYaw - rotationYaw, 3, true);
      float pitchDifference = clampAngle(targetPitch - rotationPitch, 3, true);
View Full Code Here

 
  private int getPartClicked(EntityPlayer player, double reachDistance, TileEntityRedNetCable cable)
  {
    AxisAlignedBB[] wireparts = getParts(cable);
   
    Vec3 playerPosition = Vec3.createVectorHelper(player.posX - cable.xCoord, player.posY - cable.yCoord + player.getEyeHeight(), player.posZ - cable.zCoord);
    Vec3 playerLook = player.getLookVec();
   
    Vec3 playerViewOffset = Vec3.createVectorHelper(playerPosition.xCoord + playerLook.xCoord * reachDistance, playerPosition.yCoord + playerLook.yCoord * reachDistance, playerPosition.zCoord + playerLook.zCoord * reachDistance);
    int closest = -1;
    double closestdistance = Double.MAX_VALUE;
   
    for(int i = 0; i < wireparts.length; i++)
    {
View Full Code Here

    {
      return null;
    }
   
    double range = 64;
    Vec3 playerPos = Minecraft.getMinecraft().renderViewEntity.getPosition(1.0F);
   
    Vec3 playerLook = Minecraft.getMinecraft().renderViewEntity.getLook(1.0F);
    Vec3 playerLookRel = playerPos.addVector(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range);
    List<?> list = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(Minecraft.getMinecraft().renderViewEntity,
        Minecraft.getMinecraft().renderViewEntity.boundingBox.addCoord(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range)
            .expand(1, 1, 1));
   
    double entityDistTotal = range;
View Full Code Here

    }
   
    double range = MFRConfig.spyglassRange.getInt();
    MovingObjectPosition objHit = Minecraft.getMinecraft().renderViewEntity.rayTrace(range, 1.0F);
    double blockDist = range;
    Vec3 playerPos = Minecraft.getMinecraft().renderViewEntity.getPosition(1.0F);
   
    if(objHit != null)
    {
      blockDist = objHit.hitVec.distanceTo(playerPos);
    }
   
    Vec3 playerLook = Minecraft.getMinecraft().renderViewEntity.getLook(1.0F);
    Vec3 playerLookRel = playerPos.addVector(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range);
    List<?> list = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(
        Minecraft.getMinecraft().renderViewEntity,
        Minecraft.getMinecraft().renderViewEntity.boundingBox.addCoord(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range).expand(1, 1, 1));
   
    double entityDistTotal = blockDist;
View Full Code Here

    double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
    double d1 = player.prevPosY + (player.posY - player.prevPosY) * f;
    if (!world.isRemote && player instanceof EntityPlayer)
      d1 += 1.62D;
    double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * 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 = range;
    Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
    return world.rayTraceBlocks(vec3, vec31, par3);
  }
View Full Code Here

    double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
    double d1 = player.prevPosY + (player.posY - player.prevPosY) * f;
    if (!world.isRemote && player instanceof EntityPlayer)
      d1 += 1.62D;
    double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * 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 = range;
    if (player instanceof EntityPlayerMP)
      d3 = ((EntityPlayerMP) player).theItemInWorldManager.getBlockReachDistance();
    Vec3 vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
    return world.func_147447_a(vec3, vec31, par3, !par3, par3);
  }
View Full Code Here

TOP

Related Classes of net.minecraft.util.Vec3

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.