Package net.minecraft.util

Examples of net.minecraft.util.MovingObjectPosition


    Minecraft mc = Minecraft.getMinecraft();
    Profiler profiler = mc.mcProfiler;

    if(event.type == ElementType.ALL) {
      profiler.startSection("botania-hud");
      MovingObjectPosition pos = mc.objectMouseOver;
      if(pos != null) {
        Block block = mc.theWorld.getBlock(pos.blockX, pos.blockY, pos.blockZ);
        TileEntity tile = mc.theWorld.getTileEntity(pos.blockX, pos.blockY, pos.blockZ);
        ItemStack stack = mc.thePlayer.getCurrentEquippedItem();
View Full Code Here


        if(player instanceof EntityPlayerMP)
          ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, nbttagcompound));
      }
      worldObj.playSoundAtEntity(player, "botania:ding", 0.1F, 1F);
    } else {
      MovingObjectPosition pos = raytraceFromEntity(worldObj, player, true, 5);
      if(pos != null && pos.hitVec != null && !worldObj.isRemote) {
        double x = pos.hitVec.xCoord - xCoord - 0.5;
        double y = pos.hitVec.yCoord - yCoord - 0.5;
        double z = pos.hitVec.zCoord - zCoord - 0.5;
View Full Code Here

    World world = player.worldObj;
    Material mat = world.getBlock(x, y, z).getMaterial();
    if(!ToolCommons.isRightMaterial(mat, MATERIALS))
      return false;

    MovingObjectPosition block = ToolCommons.raytraceFromEntity(world, player, true, 4.5);
    if(block == null)
      return false;

    ForgeDirection direction = ForgeDirection.getOrientation(block.sideHit);
    int fortune = EnchantmentHelper.getFortuneModifier(player);
View Full Code Here

  public void onUpdate() {
    super.onUpdate();
    Vec3 vec3 = Vec3.createVectorHelper(posX, posY, posZ);
    Vec3 vec31 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);

    MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31);


    if (!worldObj.isRemote)
    {
      Entity entity = null;
      List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX*2, motionY*2, motionZ*2).expand(2.0D, 2.0D, 2.0D));
      double d0 = 0.0D;

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

        if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0))
        {
          float f = 1.0F;
          AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f);
          MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);

          if (movingobjectposition1 != null)
          {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

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

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

    if (movingobjectposition != null)
    {
View Full Code Here

    setUnlocalizedName(LibItemNames.OPEN_BUCKET);
  }

  @Override
  public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true);

    if(movingobjectposition == null)
      return par1ItemStack;
    else {
      if(movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
View Full Code Here

            if(!par3World.isRemote)
              par3World.playSoundAtEntity(par2EntityPlayer, "botania:lexiconOpen", 0.5F, 1F);
            return true;
          }
        } else if(par3World.isRemote) {
          MovingObjectPosition pos = new MovingObjectPosition(par4, par5, par6, par7, Vec3.createVectorHelper(par8, par9, par10));
          return Botania.proxy.openWikiPage(par3World, block, pos);
        }
      }
    }
View Full Code Here

    if(throwableShake > 0)
      --throwableShake;

    Vec3 vec3 = new Vector3(posX, posY, posZ).toVec3D();
    Vec3 vec31 = new Vector3(posX + motionX, posY + motionY, posZ + motionZ).toVec3D();
    MovingObjectPosition movingobjectposition = clip(vec3, vec31);

    if(movingobjectposition != null)
      vec31 = new Vector3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord).toVec3D();

    if(!worldObj.isRemote) {
      Entity entity = null;
      List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
      double d0 = 0.0D;
      EntityLivingBase entitylivingbase = getThrower();

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

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

          if(movingobjectposition1 != null) {
            double d1 = vec3.distanceTo(movingobjectposition1.hitVec);

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

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

    if(movingobjectposition != null)
      onImpact(movingobjectposition);
View Full Code Here

        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

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

    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

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.