Examples of MovingObjectPosition


Examples of net.minecraft.util.MovingObjectPosition

    {
      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

Examples of net.minecraft.util.MovingObjectPosition

      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

Examples of net.minecraft.util.MovingObjectPosition

  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

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

Examples of net.minecraft.util.MovingObjectPosition

        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

Examples of net.minecraft.util.MovingObjectPosition

    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

Examples of net.minecraft.util.MovingObjectPosition

  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

Examples of net.minecraft.util.MovingObjectPosition

    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

Examples of net.minecraft.util.MovingObjectPosition

            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

Examples of net.minecraft.util.MovingObjectPosition

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