Package net.minecraft.util

Examples of net.minecraft.util.MovingObjectPosition


          AttachmentType grip = type.getGrip(currentHeldItem);
          if(grip != null && grip.flashlight)
          {
            for(int i = 0; i < 2; i++)
            {
              MovingObjectPosition ray = player.rayTrace(grip.flashlightRange / 2F * (i + 1), 1F);
              if(ray != null)
              {
                int x = ray.blockX;
                int y = ray.blockY;
                int z = ray.blockZ;
View Full Code Here


        ++this.field_146047_aw;
      }

      Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3);
      vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
      vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);

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

      Entity entity = null;
      List<Entity> 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;
      double d2;

      for (int i = 0; i < list.size(); i++) {
        Entity entity1 = list.get(i);

        if (entity1.canBeCollidedWith() && (entity1 != this.field_146042_b || this.field_146047_aw >= 5)) {
          float f = 0.3F;
          AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f);
          MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec31, vec3);

          if (movingobjectposition1 != null) {
            d2 = vec31.distanceTo(movingobjectposition1.hitVec);

            if (d2 < d0 || d0 == 0.0D) {
              entity = entity1;
              d0 = d2;
            }
          }
        }
      }

      if (entity != null) {
        movingobjectposition = new MovingObjectPosition(entity);
      }

      if (movingobjectposition != null) {
        if (movingobjectposition.entityHit != null) {
          if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.field_146042_b), 0.0F)) {
View Full Code Here

  }

  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {

    MovingObjectPosition pos = this.getMovingObjectPositionFromPlayer(world, player, false);

    if (pos == null || pos.typeOfHit != MovingObjectType.BLOCK) {
      return stack;
    }
    int x = pos.blockX;
View Full Code Here

    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;
      mop.blockZ = pos.z;
View Full Code Here

    return mop;
  }

  public MovingObjectPosition rayTraceCuboid(Vector3 start, Vector3 end, Cuboid6 cuboid, Entity e) {

    MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
    if (mop != null) {
      mop.typeOfHit = MovingObjectType.ENTITY;
      mop.entityHit = e;
    }
    return mop;
View Full Code Here

  }

  public MovingObjectPosition rayTraceCuboids(Vector3 start, Vector3 end, List<IndexedCuboid6> cuboids) {

    double c_dist = Double.MAX_VALUE;
    MovingObjectPosition c_hit = null;

    for (IndexedCuboid6 cuboid : cuboids) {
      MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
      if (mop != null && s_dist < c_dist) {
        mop = new ExtendedMOP(mop, cuboid.data, s_dist);
        c_dist = s_dist;
        c_hit = mop;
        c_cuboid = cuboid;
View Full Code Here

    return c_hit;
  }

  public MovingObjectPosition rayTraceCuboids(Vector3 start, Vector3 end, List<IndexedCuboid6> cuboids, BlockCoord pos, Block block) {

    MovingObjectPosition mop = rayTraceCuboids(start, end, cuboids);
    if (mop != null) {
      mop.typeOfHit = MovingObjectType.BLOCK;
      mop.blockX = pos.x;
      mop.blockY = pos.y;
      mop.blockZ = pos.z;
View Full Code Here

  }

  public void rayTraceCuboids(Vector3 start, Vector3 end, List<IndexedCuboid6> cuboids, BlockCoord pos, Block block, List<ExtendedMOP> hitList) {

    for (IndexedCuboid6 cuboid : cuboids) {
      MovingObjectPosition mop = rayTraceCuboid(start, end, cuboid);
      if (mop != null) {
        ExtendedMOP emop = new ExtendedMOP(mop, cuboid.data, s_dist);
        emop.typeOfHit = MovingObjectType.BLOCK;
        emop.blockX = pos.x;
        emop.blockY = pos.y;
View Full Code Here

                }
            }
        }
        else
        {
            MovingObjectPosition mop = FunctionHelper.getPlayerLookingSpot(sender, 500);
            if (mop == null)
            {
                OutputHandler.chatError(sender, "You must first look at the ground!");
            }
            else
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.