Examples of MovingObjectPosition


Examples of net.minecraft.util.MovingObjectPosition

    return getCurrentMovingObjectPosition(player, player.capabilities.isCreativeMode ? 5.0F : 4.5F);
  }

  public static int getCurrentMousedOverSide(EntityPlayer player) {

    MovingObjectPosition mouseOver = getCurrentMovingObjectPosition(player);
    return mouseOver == null ? 0 : mouseOver.sideHit;
  }
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

        int j1 = MathHelper.floor_double(startVec.zCoord);
        Block block = world.getBlock(l, i1, j1);
        int k1 = world.getBlockMetadata(l, i1, j1);

        if((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) && block.canCollideCheck(k1, includeLiquids)) {
          MovingObjectPosition movingobjectposition = block.collisionRayTrace(world, l, i1, j1, startVec, endVec);
          if(movingobjectposition != null) {
            result.add(movingobjectposition);
          }
        }

        MovingObjectPosition movingobjectposition2 = null;
        k1 = 200;

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

          if(l == i && i1 == j && j1 == k) {
            if(p_147447_5_) {
              result.add(movingobjectposition2);
            } else {
              return result;
            }
          }

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

          if(i > l) {
            d0 = (double) l + 1.0D;
          } else if(i < l) {
            d0 = (double) l + 0.0D;
          } else {
            flag6 = false;
          }

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

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

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

          if(flag6) {
            d3 = (d0 - startVec.xCoord) / d6;
          }
          if(flag3) {
            d4 = (d1 - startVec.yCoord) / d7;
          }
          if(flag4) {
            d5 = (d2 - startVec.zCoord) / d8;
          }

          boolean flag5 = false;
          byte b0;

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

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

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

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

          Vec3 vec32 = Vec3.createVectorHelper(startVec.xCoord, startVec.yCoord, startVec.zCoord);
          l = (int) (vec32.xCoord = (double) MathHelper.floor_double(startVec.xCoord));
          if(b0 == 5) {
            --l;
            ++vec32.xCoord;
          }

          i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(startVec.yCoord));

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

          j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(startVec.zCoord));

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

          Block block1 = world.getBlock(l, i1, j1);
          int l1 = world.getBlockMetadata(l, i1, j1);

          if(!p_147447_4_ || block1.getCollisionBoundingBoxFromPool(world, l, i1, j1) != null) {
            if(block1.canCollideCheck(l1, includeLiquids)) {
              MovingObjectPosition movingobjectposition1 = block1.collisionRayTrace(world, l, i1, j1, startVec, endVec);
              if(movingobjectposition1 != null) {
                result.add(movingobjectposition1);
              }
            } else {
              movingobjectposition2 = new MovingObjectPosition(l, i1, j1, b0, startVec, false);
            }
          }
        }
        if(p_147447_5_ ) {
          result.add(movingobjectposition2);
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

    List<MovingObjectPosition> hits = new ArrayList<MovingObjectPosition>();

    for (BlockCoord bc : configurables) {
      Block block = world.getBlock(bc.x, bc.y, bc.z);
      if(block != null) {
        MovingObjectPosition hit = block.collisionRayTrace(world, bc.x, bc.y, bc.z, Vec3.createVectorHelper(start.x, start.y, start.z),
            Vec3.createVectorHelper(end.x, end.y, end.z));
        if(hit != null) {
          hits.add(hit);
        }
      }
    }
    selection = null;
    MovingObjectPosition hit = getClosestHit(Vec3.createVectorHelper(start.x, start.y, start.z), hits);   
    if(hit != null) {
      TileEntity te = world.getTileEntity(hit.blockX, hit.blockY, hit.blockZ);     
      if(te instanceof IIoConfigurable) {
        IIoConfigurable configuarble = (IIoConfigurable) te;
        ForgeDirection face = ForgeDirection.getOrientation(hit.sideHit);
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

    double playerHeight = player.yOffset;
    //if you looking at you feet, and your player height to the max distance, or part there of
    double lookComp = -look.y * playerHeight;
    double maxDistance = Config.travelStaffMaxBlinkDistance + lookComp;

    MovingObjectPosition p = player.worldObj.rayTraceBlocks(eye3, end, !Config.travelStaffBlinkThroughClearBlocksEnabled);
    if(p == null) {

      //go as far as possible
      for (double i = maxDistance; i > 1; i--) {

View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

    final AxisAlignedBB aabb = block.getCollisionBoundingBoxFromPool(w, bc.x, bc.y, bc.z);
    return aabb == null || aabb.getAverageEdgeLength() < 0.7;
  }

  private boolean canBlinkTo(BlockCoord bc, World w, Vec3 start, Vec3 target) {
    MovingObjectPosition p = w.rayTraceBlocks(start, target, !Config.travelStaffBlinkThroughClearBlocksEnabled);
    if(p != null) {
      if(!Config.travelStaffBlinkThroughClearBlocksEnabled) {
        return false;
      }
      Block block = w.getBlock(p.blockX, p.blockY, p.blockZ);
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

    start.add(origin);
    end.add(origin);
    List<MovingObjectPosition> hits = new ArrayList<MovingObjectPosition>();
    for (ViewableBlocks ug : blocks) {
      if(!ug.bc.equals(new BlockCoord(ioX, ioY, ioZ))) {
        MovingObjectPosition res = player.worldObj.rayTraceBlocks(Vec3.createVectorHelper(start.x, start.y, start.z),
            Vec3.createVectorHelper(end.x, end.y, end.z), false);

        if(res != null) {
          hits.add(res);
        }
      }
    }
    MovingObjectPosition hit = getClosestHit(Vec3.createVectorHelper(start.x, start.y, start.z), hits);
    if(hit != null) {
      Block block = world.getBlock(hit.blockX, hit.blockY, hit.blockZ);
      if(block == EnderIO.blockHyperCube || block == EnderIO.blockCapacitorBank) {
        block.onBlockActivated(world, hit.blockX, hit.blockY, hit.blockZ, player, 0, 0, 0, 0);
      } else {
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

  }

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

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

Examples of net.minecraft.util.MovingObjectPosition

    Block block = accessor.getBlock();
    TileEntity te = accessor.getTileEntity();
    Item item = Item.getItemFromBlock(block);
    EntityPlayer player = accessor.getPlayer();
    World world = player.worldObj;
    MovingObjectPosition pos = accessor.getPosition();

    int x = pos.blockX, y = pos.blockY, z = pos.blockZ;

    if(block instanceof AbstractMachineBlock<?>) {
      if(te != null && te instanceof AbstractMachineEntity) {
View Full Code Here

Examples of net.minecraft.util.MovingObjectPosition

    }
  }

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

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

Examples of net.minecraft.util.MovingObjectPosition

    IConduitBundle bundle = (IConduitBundle) te;
    List<RaytraceResult> hits = new ArrayList<RaytraceResult>();

    if(ConduitUtil.isSolidFacadeRendered(bundle, player)) {
      setBlockBounds(0, 0, 0, 1, 1, 1);
      MovingObjectPosition hitPos = super.collisionRayTrace(world, x, y, z,
          origin, direction);
      if(hitPos != null) {
        hits.add(new RaytraceResult(new CollidableComponent(null,
            BoundingBox.UNIT_CUBE, ForgeDirection.UNKNOWN, null), hitPos));
      }
    } else {

      Collection<CollidableComponent> components =
          new ArrayList<CollidableComponent>(bundle.getCollidableComponents());
      for (CollidableComponent component : components) {
        setBlockBounds(component.bound.minX, component.bound.minY,
            component.bound.minZ, component.bound.maxX, component.bound.maxY,
            component.bound.maxZ);
        MovingObjectPosition hitPos = super.collisionRayTrace(world, x, y, z,
            origin, direction);
        if(hitPos != null) {
          hits.add(new RaytraceResult(component, hitPos));
        }
      }

      // safety to prevent unbreakable empty bundles in case of a bug
      if(bundle.getConduits().isEmpty() && !ConduitUtil.isFacadeHidden(bundle,
          player)) {
        setBlockBounds(0, 0, 0, 1, 1, 1);
        MovingObjectPosition hitPos = super.collisionRayTrace(world, x, y, z,
            origin, direction);
        if(hitPos != null) {
          hits.add(new RaytraceResult(null, hitPos));
        }
      }
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.