Examples of MovingObjectPosition


Examples of net.minecraft.util.MovingObjectPosition

        int j1 = MathHelper.floor_double(par1Vec3.zCoord);
        Block block = worldObj.getBlock(l, i1, j1);
        int l1 = worldObj.getBlockMetadata(l, i1, j1);

        if (block != null && (!par4 || block == null || block.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) && block != Blocks.air && block.canCollideCheck(l1, par3)) {
          MovingObjectPosition movingobjectposition = block.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3);

          if (movingobjectposition != null)
            return movingobjectposition;
        }

        int k1 = 200;

        while (k1-- >= 0) {
          if (Double.isNaN(par1Vec3.xCoord) || Double.isNaN(par1Vec3.yCoord) || Double.isNaN(par1Vec3.zCoord))
            return null;

          if (l == i && i1 == j && j1 == k)
            return null;

          boolean flag2 = true;
          boolean flag3 = true;
          boolean flag4 = true;
          double d0 = 999.0D;
          double d1 = 999.0D;
          double d2 = 999.0D;

          if (i > l)
            d0 = l + 1.0D;
          else if (i < l)
            d0 = l + 0.0D;
          else flag2 = false;

          if (j > i1)
            d1 = i1 + 1.0D;
          else if (j < i1)
            d1 = i1 + 0.0D;
          else flag3 = false;

          if (k > j1)
            d2 = j1 + 1.0D;
          else if (k < j1)
            d2 = j1 + 0.0D;
          else flag4 = false;

          double d3 = 999.0D;
          double d4 = 999.0D;
          double d5 = 999.0D;
          double d6 = par2Vec3.xCoord - par1Vec3.xCoord;
          double d7 = par2Vec3.yCoord - par1Vec3.yCoord;
          double d8 = par2Vec3.zCoord - par1Vec3.zCoord;

          if (flag2)
            d3 = (d0 - par1Vec3.xCoord) / d6;

          if (flag3)
            d4 = (d1 - par1Vec3.yCoord) / d7;

          if (flag4)
            d5 = (d2 - par1Vec3.zCoord) / d8;

          byte b0;

          if (d3 < d4 && d3 < d5) {
            if (i > l)
              b0 = 4;
            else b0 = 5;

            par1Vec3.xCoord = d0;
            par1Vec3.yCoord += d7 * d3;
            par1Vec3.zCoord += d8 * d3;
          } else if (d4 < d5) {
            if (j > i1)
              b0 = 0;
            else b0 = 1;

            par1Vec3.xCoord += d6 * d4;
            par1Vec3.yCoord = d1;
            par1Vec3.zCoord += d8 * d4;
          } else {
            if (k > j1)
              b0 = 2;
            else b0 = 3;

            par1Vec3.xCoord += d6 * d5;
            par1Vec3.yCoord += d7 * d5;
            par1Vec3.zCoord = d2;
          }

          Vec3 vec32 = new Vector3(par1Vec3.xCoord, par1Vec3.yCoord, par1Vec3.zCoord).toVec3D();
          l = (int)(vec32.xCoord = MathHelper.floor_double(par1Vec3.xCoord));

          if (b0 == 5) {
            --l;
            ++vec32.xCoord;
          }

          i1 = (int)(vec32.yCoord = MathHelper.floor_double(par1Vec3.yCoord));

          if (b0 == 1) {
            --i1;
            ++vec32.yCoord;
          }

          j1 = (int)(vec32.zCoord = MathHelper.floor_double(par1Vec3.zCoord));

          if (b0 == 3) {
            --j1;
            ++vec32.zCoord;
          }

          Block block1 = worldObj.getBlock(l, i1, j1);
          int j2 = worldObj.getBlockMetadata(l, i1, j1);

          if ((!par4 || block1 == null || block1.getCollisionBoundingBoxFromPool(worldObj, l, i1, j1) != null) && block1 != Blocks.air && block1.canCollideCheck(j2, par3)) {
            MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(worldObj, l, i1, j1, par1Vec3, par2Vec3);

            if (movingobjectposition1 != null)
              return movingobjectposition1;
          }
        }
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

        }
    }
   
    public static boolean place(EntityPlayer player, World world)
    {
        MovingObjectPosition hit = RayTracer.reTrace(world, player);
        if(hit == null)
            return false;
       
        BlockCoord pos = new BlockCoord(hit.blockX, hit.blockY, hit.blockZ).offset(hit.sideHit);
        ItemStack held = player.getHeldItem();
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

    return rayTrace(world, reachPoint, collisionFlag);
  }

  public MovingObjectPosition rayTrace(World world, Vector3 reachPoint, boolean collisionFlag)
  {
    MovingObjectPosition pickedBlock = this.rayTraceBlocks(world, reachPoint.clone(), collisionFlag);
    MovingObjectPosition pickedEntity = this.rayTraceEntities(world, reachPoint.clone());

    if (pickedBlock == null)
    {
      return pickedEntity;
    }
View Full Code Here

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

Examples of net.minecraft.util.MovingObjectPosition

  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

Examples of net.minecraft.util.MovingObjectPosition

    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

Examples of net.minecraft.util.MovingObjectPosition

    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

Examples of net.minecraft.util.MovingObjectPosition

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

Examples of net.minecraft.util.MovingObjectPosition

    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

Examples of net.minecraft.util.MovingObjectPosition

    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
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.