Package net.minecraft.util

Examples of net.minecraft.util.MovingObjectPosition


   * getDeltaPositionFromRotation()
   * @return The target hit.
   */
  public MovingObjectPosition rayTraceEntities(World world, Vector3 target)
  {
    MovingObjectPosition pickedEntity = null;
    Vec3 startingPosition = toVec3();
    Vec3 look = target.toVec3();
    double reachDistance = distance(target);
    //Vec3 reachPoint = Vec3.createVectorHelper(startingPosition.xCoord + look.xCoord * reachDistance, startingPosition.yCoord + look.yCoord * reachDistance, startingPosition.zCoord + look.zCoord * reachDistance);

    double checkBorder = 1.1 * reachDistance;
    AxisAlignedBB boxToScan = AxisAlignedBB.getAABBPool().getAABB(-checkBorder, -checkBorder, -checkBorder, checkBorder, checkBorder, checkBorder).offset(this.x, this.y, this.z);

    @SuppressWarnings("unchecked")
    List<Entity> entitiesInBounds = world.getEntitiesWithinAABBExcludingEntity(null, boxToScan);
    double closestEntity = reachDistance;
   
    if (entitiesInBounds == null || entitiesInBounds.isEmpty())
    {
      return null;
    }
    for (Entity possibleHits : entitiesInBounds)
    {
      if (possibleHits != null && possibleHits.canBeCollidedWith() && possibleHits.boundingBox != null)
      {
        float border = possibleHits.getCollisionBorderSize();
        AxisAlignedBB aabb = possibleHits.boundingBox.expand(border, border, border);
        MovingObjectPosition hitMOP = aabb.calculateIntercept(startingPosition, target.toVec3());

        if (hitMOP != null)
        {
          if (aabb.isVecInside(startingPosition))
          {
            if (0.0D < closestEntity || closestEntity == 0.0D)
            {
              pickedEntity = new MovingObjectPosition(possibleHits);
              if (pickedEntity != null)
              {
                pickedEntity.hitVec = hitMOP.hitVec;
                closestEntity = 0.0D;
              }
            }
          }
          else
          {
            double distance = startingPosition.distanceTo(hitMOP.hitVec);

            if (distance < closestEntity || closestEntity == 0.0D)
            {
              pickedEntity = new MovingObjectPosition(possibleHits);
              pickedEntity.hitVec = hitMOP.hitVec;
              closestEntity = distance;
            }
          }
        }
View Full Code Here


  public ChunkCoordinates getBinding(ItemStack stack) {
    ChunkCoordinates bound = getBoundTile(stack);
    if(bound.posY != -1)
      return bound;

    MovingObjectPosition pos = Minecraft.getMinecraft().objectMouseOver;
    if(pos != null) {
      TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
      if(tile != null && tile instanceof ITileBound) {
        ChunkCoordinates coords = ((ITileBound) tile).getBinding();
        return coords;
View Full Code Here

    for(EntityPlayer player : players) {
      ItemStack helm = player.getCurrentArmor(3);
      if(helm != null && helm.getItem() == Item.getItemFromBlock(Blocks.pumpkin))
        continue;

      MovingObjectPosition pos = ToolCommons.raytraceFromEntity(worldObj, player, true, 64);
      if(pos != null && pos.blockX == xCoord && pos.blockY == yCoord && pos.blockZ == zCoord) {
        looking = true;
        break;
      }
    }
View Full Code Here

    TileEntity tileEntity = (TileEntity)configurable;
    EntityPlayer player = mc.thePlayer;
    World world = mc.thePlayer.worldObj;
    ItemStack itemStack = player.getCurrentEquippedItem();
    MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F);

    if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator && ((ItemConfigurator)itemStack.getItem()).getState(itemStack) == 0)
    {
      int xPos = MathHelper.floor_double(pos.blockX);
      int yPos = MathHelper.floor_double(pos.blockY);
View Full Code Here

        }
      }
    }
    else if(type == MachineType.PORTABLE_TANK && getBucketMode(itemstack))
      {
          MovingObjectPosition pos = getMovingObjectPositionFromPlayer(world, entityplayer, !entityplayer.isSneaking());
         
          if(pos == null)
          {
              return itemstack;
          }
View Full Code Here

    if(this == Mekanism.BasicBlock)
    {
      if(!world.isRemote && meta == 6)
      {
        TileEntityBin bin = (TileEntityBin)world.getTileEntity(x, y, z);
        MovingObjectPosition pos = MekanismUtils.rayTrace(world, player);

        if(pos != null && pos.sideHit == bin.facing)
        {
          if(bin.bottomStack != null)
          {
View Full Code Here

    if(transporter instanceof PartDiversionTransporter)
    {
      EntityPlayer player = mc.thePlayer;
      World world = mc.thePlayer.worldObj;
      ItemStack itemStack = player.getCurrentEquippedItem();
      MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F);

      if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator)
      {
        int xPos = MathHelper.floor_double(pos.blockX);
        int yPos = MathHelper.floor_double(pos.blockY);
View Full Code Here

        EntityPlayer player = mc.thePlayer;
        World world = mc.thePlayer.worldObj;
 
        FontRenderer font = mc.fontRenderer;
 
        MovingObjectPosition pos = player.rayTrace(40.0D, 1.0F);
 
        if(pos != null)
        {
          int x = MathHelper.floor_double(pos.blockX);
          int y = MathHelper.floor_double(pos.blockY);
View Full Code Here

            traceSide(i, start, end, cuboid);
       
        if(s_side < 0)
            return null;
       
        MovingObjectPosition mop = new MovingObjectPosition(0, 0, 0, s_side, s_vec.toVec3D());
        mop.typeOfHit = null;
        return mop;
    }
View Full Code Here

        return mop;
    }

    public MovingObjectPosition rayTraceCuboid(Vector3 start, Vector3 end, Cuboid6 cuboid, BlockCoord pos)
    {
        MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
        if(mop != null)
        {
            mop.typeOfHit = MovingObjectType.BLOCK;
            mop.blockX = pos.x;
            mop.blockY = pos.y;
View Full Code Here

TOP

Related Classes of net.minecraft.util.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.