Package crazypants.vecmath

Examples of crazypants.vecmath.Vector3d


  private boolean isMobInRange(EntityLiving mob, int range) {
    if(mob == null) {
      return false;
    }
    return new Vector3d(mob.posX, mob.posY, mob.posZ).distanceSquared(new Vector3d(xCoord, yCoord, zCoord)) <= range;
  }
View Full Code Here


    }
    return true;
  }

  public boolean doBlink(ItemStack equipped, EntityPlayer player) {
    Vector3d eye = Util.getEyePositionEio(player);
    Vector3d look = Util.getLookVecEio(player);

    Vector3d sample = new Vector3d(look);
    sample.scale(Config.travelStaffMaxBlinkDistance);
    sample.add(eye);
    Vec3 eye3 = Vec3.createVectorHelper(eye.x, eye.y, eye.z);
    Vec3 end = Vec3.createVectorHelper(sample.x, sample.y, sample.z);

    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--) {

        sample.set(look);
        sample.scale(i);
        sample.add(eye);
        //we test against our feets location
        sample.y -= playerHeight;
        if(doBlinkAround(player, sample, true)) {
          return true;
        }
      }
      return false;
    } else {

      List<MovingObjectPosition> res = Util.raytraceAll(player.worldObj, eye3, end, !Config.travelStaffBlinkThroughClearBlocksEnabled);
      for (MovingObjectPosition pos : res) {
        if(pos != null) {
          Block hitBlock = player.worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
          if(isBlackListedBlock(player, pos, hitBlock)) {
            maxDistance = Math.min(maxDistance, VecmathUtil.distance(eye, new Vector3d(pos.blockX + 0.5, pos.blockY + 0.5, pos.blockZ + 0.5)) - 1.5 - lookComp);           
          }
        }
      }

      eye3 = Vec3.createVectorHelper(eye.x, eye.y, eye.z);

      Vector3d targetBc = new Vector3d(p.blockX, p.blockY, p.blockZ);
      double sampleDistance = 1.5;     
      double teleDistance = VecmathUtil.distance(eye, new Vector3d(p.blockX + 0.5, p.blockY + 0.5, p.blockZ + 0.5)) + sampleDistance;
     
      while (teleDistance < maxDistance) {
        sample.set(look);
        sample.scale(sampleDistance);
        sample.add(targetBc);
        //we test against our feets location
        sample.y -= playerHeight;

        if(doBlinkAround(player, sample, false)) {
          return true;
        }
        teleDistance++;
        sampleDistance++;
      }
      sampleDistance = -0.5;
      teleDistance = VecmathUtil.distance(eye, new Vector3d(p.blockX + 0.5, p.blockY + 0.5, p.blockZ + 0.5)) + sampleDistance;
      while (teleDistance > 1) {
        sample.set(look);
        sample.scale(sampleDistance);
        sample.add(targetBc);
        //we test against our feets location
View Full Code Here

  @SubscribeEvent
  public void onRender(RenderWorldLastEvent event) {

    Minecraft mc = Minecraft.getMinecraft();
    Vector3d eye = Util.getEyePositionEio(mc.thePlayer);
    Vector3d lookAt = Util.getLookVecEio(mc.thePlayer);
    lookAt.add(eye);
    Matrix4d mv = VecmathUtil.createMatrixAsLookAt(eye, lookAt, new Vector3d(0, 1, 0));

    float fov = Minecraft.getMinecraft().gameSettings.fovSetting;       
    Matrix4d pr = VecmathUtil.createProjectionMatrixAsPerspective(fov, 0.05f, mc.gameSettings.renderDistanceChunks * 16, mc.displayWidth,
        mc.displayHeight);      
    currentView.setProjectionMatrix(pr);
View Full Code Here

  private double getDistanceSquared(EntityPlayer player, BlockCoord bc) {
    if(player == null || bc == null) {
      return 0;
    }
    Vector3d eye = Util.getEyePositionEio(player);
    Vector3d target = new Vector3d(bc.x + 0.5, bc.y + 0.5, bc.z + 0.5);
    return eye.distanceSquared(target);
  }
View Full Code Here

      if(isClear(w, block, p.blockX, p.blockY, p.blockZ)) {
        if(new BlockCoord(p.blockX, p.blockY, p.blockZ).equals(bc)) {
          return true;
        }
        //need to step
        Vector3d sv = new Vector3d(start.xCoord, start.yCoord, start.zCoord);
        Vector3d rayDir = new Vector3d(target.xCoord, target.yCoord, target.zCoord);
        rayDir.sub(sv);
        rayDir.normalize();
        rayDir.add(sv);
        return canBlinkTo(bc, w, Vec3.createVectorHelper(rayDir.x, rayDir.y, rayDir.z), target);

      } else {
        return false;
      }
View Full Code Here

      }
    }

    if(selectedCoord != null) {
     
      Vector3d blockCenter = new Vector3d(selectedCoord.x + 0.5, selectedCoord.y + 0.5, selectedCoord.z + 0.5);
      Vector2d blockCenterPixel = currentView.getScreenPoint(blockCenter);           
     
      Vector2d screenMidPixel = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
      screenMidPixel.scale(0.5);
View Full Code Here

    float end = 0.01f;
    double mix = MathHelper.clamp_float((start - ratio) / (start - end), 0, 1);
    double scale = 1;
    if(mix > 0) {
     
      Vector3d eyePoint = Util.getEyePositionEio(EnderIO.proxy.getClientPlayer());     
      scale = tanFovRad * eyePoint.distance(loc);
     
      //Using this scale will give us the block full screen, we will make it 20% of the screen
      scale *= Config.travelAnchorZoomScale;     

      //only apply 70% of the scaling so more distance targets are still smaller than closer targets
      float nf = 1 - MathHelper.clamp_float((float) eyePoint.distanceSquared(loc) / TravelSource.STAFF.maxDistanceTravelledSq, 0, 1);
      scale = scale * (0.3 + 0.7 * nf);

      scale = (scale * mix) + (1 - mix);
      scale = Math.max(1, scale);
     
View Full Code Here

    }
    return scale;
  }

  private double addRatio(BlockCoord bc) {
    Vector2d sp = currentView.getScreenPoint(new Vector3d(bc.x + 0.5, bc.y + 0.5, bc.z + 0.5));
    Vector2d mid = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
    mid.scale(0.5);
    double d = sp.distance(mid);
    if(d != d) {
      d = 0f
View Full Code Here

      float fullness = (float) (tank.getFluidAmount()) / (tank.getCapacity());
      BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.85, 0.96, 0.85);
      bb = bb.scale(1, 0.85 * fullness, 1);
      float ty = -(0.85f - (bb.maxY - bb.minY)) / 2;

      Vector3d offset = ForgeDirectionOffsets.offsetScaled(ForgeDirection.values()[gen.facing], -0.075);
      bb = bb.translate((float) offset.x, ty, (float) offset.z);

      int brightness;
      if(gen.getWorldObj() == null) {
        brightness = 15 << 20 | 15 << 4;
View Full Code Here

      if(te instanceof TileEndermanSkull) {
        yaw = ((TileEndermanSkull)te).yaw;
      }
    }
   
    VertexRotation rot = new VertexRotation(Math.toRadians(yaw), new Vector3d(0,1,0), new Vector3d(0.5,0,0.5));
   
    float size = 0.25f;
    float height = 0.5f;
    BoundingBox bb = new BoundingBox(size, 0, size, 1 - size, height, 1 - size);
    CubeRenderer.render(bb, icons, rot, true);
View Full Code Here

TOP

Related Classes of crazypants.vecmath.Vector3d

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.