Package net.minecraft.util

Examples of net.minecraft.util.MovingObjectPosition


   
    if(!worldObj.isRemote)
    {
      Vec3 pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      Vec3 nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
      MovingObjectPosition hit = this.worldObj.rayTraceBlocks_do_do(pos, nextPos, false, true);
      pos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX, this.posY, this.posZ);
      nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
     
      if(hit != null)
      {
        nextPos = this.worldObj.getWorldVec3Pool().getVecFromPool(hit.hitVec.xCoord, hit.hitVec.yCoord,  hit.hitVec.zCoord);
      }
     
      Entity entityHit = null;
      List<?> list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this,  this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
      double closestRange = 0.0D;
      double collisionRange = 0.3D;
     
      for(int i = 0, end = list.size(); i < end; ++i)
      {
        Entity e = (Entity)list.get(i);
       
        if(e.canBeCollidedWith() && (e != _owner))
        {
          AxisAlignedBB entitybb = e.boundingBox.expand(collisionRange, collisionRange, collisionRange);
          MovingObjectPosition entityHitPos = entitybb.calculateIntercept(pos, nextPos);
         
          if(entityHitPos != null)
          {
            double range = pos.distanceTo(entityHitPos.hitVec);
           
            if((range < closestRange) | closestRange == 0D)
            {
              entityHit = e;
              closestRange = range;
            }
          }
        }
      }
     
      if(entityHit != null)
      {
        hit = new MovingObjectPosition(entityHit);
      }
     
      if(hit != null && hit.entityHit != null && hit.entityHit instanceof EntityPlayer)
      {
        EntityPlayer entityplayer = (EntityPlayer)hit.entityHit;
View Full Code Here


      AxisAlignedBB part = wireparts[i];
      if(part == null)
      {
        continue;
      }
      MovingObjectPosition hit = part.calculateIntercept(playerPosition, playerViewOffset);
      if(hit != null)
      {
        double distance = playerPosition.distanceTo(hit.hitVec);
        if(distance < closestdistance)
        {
View Full Code Here

  @Override
  public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player)
  {
    if(!world.isRemote)
    {
      MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
      if(mop != null && mop.typeOfHit == EnumMovingObjectType.TILE)
      {
        int blockId = world.getBlockId(mop.blockX, mop.blockY, mop.blockZ);
        if(MFRRegistry.getLiquidDrinkHandlers().containsKey(blockId))
        {
View Full Code Here

 
 
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
  {
    MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, true);
    if(mop != null && mop.typeOfHit == EnumMovingObjectType.TILE)
    {
      if(MFRRegistry.getLiquidDrinkHandlers().containsKey(world.getBlockId(mop.blockX, mop.blockY, mop.blockZ)))
      {
        player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
View Full Code Here

  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
  {
   
    if(world.isRemote)
    {
      MovingObjectPosition mop = player.rayTrace(MFRConfig.spyglassRange.getInt(), 1.0F);
      if(mop == null || (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit == null))
      {
        player.sendChatToPlayer("Nothing in sight");
      }
      else if(mop.typeOfHit == EnumMovingObjectType.ENTITY)
View Full Code Here

     
      if(entity.canBeCollidedWith())
      {
        double entitySize = entity.getCollisionBorderSize();
        AxisAlignedBB axisalignedbb = entity.boundingBox.expand(entitySize, entitySize, entitySize);
        MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(playerPos, playerLookRel);
       
        if(axisalignedbb.isVecInside(playerPos))
        {
          if(0.0D < entityDistTotal || entityDistTotal == 0.0D)
          {
View Full Code Here

  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
  {
    if(world.isRemote)
    {
      MovingObjectPosition mop = rayTrace();
      if(mop == null || (mop.typeOfHit == EnumMovingObjectType.ENTITY && mop.entityHit == null))
      {
        player.sendChatToPlayer("Nothing in sight");
      }
      else if(mop.typeOfHit == EnumMovingObjectType.ENTITY)
View Full Code Here

    {
      return null;
    }
   
    double range = MFRConfig.spyglassRange.getInt();
    MovingObjectPosition objHit = Minecraft.getMinecraft().renderViewEntity.rayTrace(range, 1.0F);
    double blockDist = range;
    Vec3 playerPos = Minecraft.getMinecraft().renderViewEntity.getPosition(1.0F);
   
    if(objHit != null)
    {
      blockDist = objHit.hitVec.distanceTo(playerPos);
    }
   
    Vec3 playerLook = Minecraft.getMinecraft().renderViewEntity.getLook(1.0F);
    Vec3 playerLookRel = playerPos.addVector(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range);
    List<?> list = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(
        Minecraft.getMinecraft().renderViewEntity,
        Minecraft.getMinecraft().renderViewEntity.boundingBox.addCoord(playerLook.xCoord * range, playerLook.yCoord * range, playerLook.zCoord * range).expand(1, 1, 1));
   
    double entityDistTotal = blockDist;
    Entity pointedEntity = null;
    for(int i = 0; i < list.size(); ++i)
    {
      Entity entity = (Entity)list.get(i);
     
      if(entity.canBeCollidedWith())
      {
        double entitySize = entity.getCollisionBorderSize();
        AxisAlignedBB axisalignedbb = entity.boundingBox.expand(entitySize, entitySize, entitySize);
        MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(playerPos, playerLookRel);
       
        if(axisalignedbb.isVecInside(playerPos))
        {
          if(0.0D < entityDistTotal || entityDistTotal == 0.0D)
          {
            pointedEntity = entity;
            entityDistTotal = 0.0D;
          }
        }
        else if(movingobjectposition != null)
        {
          double entityDist = playerPos.distanceTo(movingobjectposition.hitVec);
         
          if(entityDist < entityDistTotal || entityDistTotal == 0.0D)
          {
            pointedEntity = entity;
            entityDistTotal = entityDist;
          }
        }
      }
    }
   
    if(pointedEntity != null && (entityDistTotal < blockDist || objHit == null))
    {
      objHit = new MovingObjectPosition(pointedEntity);
    }
    return objHit;
  }
View Full Code Here

      fractal(2, length / 100, 0, 0, 0);
      fractal(2, length / 400, 0, 0, 0);
    }

    private float rayTraceResistance(Vector3 start, Vector3 end, float prevresistance) {
      MovingObjectPosition mop = world.rayTraceBlocks(start.toVec3D(), end.toVec3D());

      if(mop == null)
        return prevresistance;

      if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
View Full Code Here

  public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPlayer player) {
    World world = player.worldObj;
    Material mat = world.getBlock(x, y, z).getMaterial();
    if (!ToolCommons.isRightMaterial(mat, materialsShovel))
      return false;
    MovingObjectPosition block = ToolCommons.raytraceFromEntity(world, player, true, 4.5);
    if (block == null)
      return false;

    ForgeDirection.getOrientation(block.sideHit);
    int fortune = EnchantmentHelper.getFortuneModifier(player);
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.