public boolean isAimingAtTarget(World world, int x, int y, int z, double[] t) {
   double[] tg = ReikaPhysicsHelper.cartesianToPolar(x - t[0], y - t[1], z - t[2]);
   tg[1] = Math.abs(tg[1]) - 90;
   float phi2 = phi;
   while (phi2 < 0) phi2 += 360;
   while (phi2 >= 360) phi2 -= 360;
   // ReikaJavaLibrary.pConsole("PHI: "+phi2+" THETA: "+theta+" for "+tg[2]+", "+tg[1]);
   if (tg[2] - phi2 > 180) tg[2] -= 360;
   if (!ReikaMathLibrary.approxr(theta, tg[1], 5)) return false;
   if (!ReikaMathLibrary.approxr(phi2, tg[2], 5)) return false;
   return true;
 }
  @SubscribeEvent
  public void markChunkCache(SetBlockEvent evt) {
    if (!evt.world.isRemote) {
      WorldChunk wc = new WorldChunk(evt.world, evt.chunkLocation);
      Collection<CrystalLink> c = losCache.get(wc);
      if (c != null) {
        for (CrystalLink l : c) {

          WorldLocation l1 = l.loc1;
          WorldLocation l2 = l.loc2;

          double[] angs =
              ReikaPhysicsHelper.cartesianToPolar(
                  l1.xCoord - l2.xCoord, l1.yCoord - l2.yCoord, l1.zCoord - l2.zCoord);
          double[] angs2 =
              ReikaPhysicsHelper.cartesianToPolar(
                  l1.xCoord - evt.xCoord, l1.yCoord - evt.yCoord, l1.zCoord - evt.zCoord);
          // Only check link if block near it
          if (ReikaMathLibrary.approxrAbs(angs[1], angs2[1], 3)
              && ReikaMathLibrary.approxrAbs(angs[2], angs2[2], 3)) {
            l.hasLOS = false;

            // Kill active flows if blocked
            for (CrystalFlow p : flows.get(evt.world.provider.dimensionId)) {
              if (!toBreak.contains(p)
                  && p.containsLink(l)
                  && !p.checkLineOfSight(l)) { // make only link check, not entire path
                CrystalNetworkLogger.logFlowBreak(p, FlowFail.SIGHT);
                this.schedulePathBreak(p);
              }
            }
          }
        }
      }
    }
  }
 public void adjustAim(World world, int x, int y, int z, double[] t) {
   if (t[3] != 1) return;
   double dx = x + 0.5 - t[0];
   double dy = y + 0.5 - t[1];
   double dz = z + 0.5 - t[2];
   double[] tg = ReikaPhysicsHelper.cartesianToPolar(dx, dy, dz);
   tg[1] = Math.abs(tg[1]) - 90 + 0.25;
   // ReikaJavaLibrary.pConsole("PHI: "+phi+" THETA: "+theta+" for "+tg[2]+", "+tg[1]);
   if (tg[2] - phi > 180) tg[2] -= 360;
   float movespeed = 1F;
   if (phi < tg[2]) phi += movespeed * 2;
   if (phi > tg[2]) phi -= movespeed * 2;
   if (theta < tg[1]) theta += movespeed;
   if (theta > tg[1]) theta -= movespeed;
   if (theta < MAXLOWANGLE && dir == 1) theta = MAXLOWANGLE;
   if (theta > -MAXLOWANGLE && dir == -1) theta = MAXLOWANGLE;
 }
示例#4
0
  public void render(double x, double y, double z, int color, boolean inworld) {
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    Tessellator v5 = Tessellator.instance;
    spline.render(v5, 0.5, 0.5, 0.5, color, inworld, true, 32);

    IIcon ico = ChromaIcons.FADE.getIcon();
    float u = ico.getMinU();
    float v = ico.getMinV();
    float du = ico.getMaxU();
    float dv = ico.getMaxV();
    BlendMode.ADDITIVEDARK.apply();
    ReikaTextureHelper.bindTerrainTexture();
    GL11.glPushMatrix();
    GL11.glTranslated(0.5, 0.5, 0.5);

    if (inworld) {
      RenderManager rm = RenderManager.instance;
      double dx = x - RenderManager.renderPosX;
      double dy = y - RenderManager.renderPosY;
      double dz = z - RenderManager.renderPosZ;
      double[] angs = ReikaPhysicsHelper.cartesianToPolar(dx, dy, dz);
      GL11.glRotated(angs[2], 0, 1, 0);
      GL11.glRotated(90 - angs[1], 1, 0, 0);
    }

    double d = 1.25;

    double pz = 0.05;

    v5.startDrawingQuads();
    int a = 160;
    v5.setColorRGBA_I(ReikaColorAPI.getColorWithBrightnessMultiplier(color, a / 255F), a);
    v5.addVertexWithUV(-d, -d, pz, u, v);
    v5.addVertexWithUV(d, -d, pz, du, v);
    v5.addVertexWithUV(d, d, pz, du, dv);
    v5.addVertexWithUV(-d, d, pz, u, dv);
    v5.draw();

    BlendMode.DEFAULT.apply();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_LIGHTING);
  }
  private void renderCore(
      TileEntityLocusPoint tile, double par2, double par4, double par6, float par8) {
    Tessellator v5 = Tessellator.instance;
    // this.renderStaticTexture(par2, par4, par6, par8);
    // BlendMode.ADDITIVEDARK.apply();
    BlendMode.ADDITIVE2.apply();
    GL11.glPushMatrix();
    GL11.glTranslated(0.5, 0.5, 0.5);
    RenderManager rm = RenderManager.instance;
    if (tile.hasWorldObj()) {
      GL11.glRotatef(-rm.playerViewY, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(rm.playerViewX, 1.0F, 0.0F, 0.0F);
    } else {
      GL11.glTranslated(0.55, 0.5, 0.5);
      GL11.glRotatef(45, 0, 1, 0);
      GL11.glRotatef(-30, 1, 0, 0);
    }

    // ReikaJavaLibrary.pConsole(te.getEnergy());

    ReikaTextureHelper.bindTexture(ChromatiCraft.class, "Textures/aurapoint2-grid.png");

    for (int i = 0; i < 3; i++) {

      int alpha = 255 - i * 64; // 255;
      int tick =
          (int)
              ((System.currentTimeMillis() / 250)
                  % 80); // (tile.getTicksExisted()*(i*3+1))%80;//+par8;
      double u = (tick % 8) / 8D; // tick/80D;//0;//0.125;
      double v = (tick / 8) / 10D; // 0;//(int)(tick/20)/4D;//0.125;
      double du = u + 1 / 8D; // u+1/80D;//u+1;//0.9375;
      double dv = v + 1 / 10D; // v+1;//0.9375;

      double s = 1 - i * 0.25;
      // for (double s = 0.5; s >= 0.25; s -= 0.0625) {

      GL11.glPushMatrix();

      double s1 = tile.isInWorld() ? s : s;

      GL11.glScaled(s1, s1, s1);
      /*
      	GL11.glMatrixMode(GL11.GL_TEXTURE);
      	GL11.glPushMatrix();

      	/*
      double d = 0.5;
      GL11.glTranslated(d, d, d);
      GL11.glRotated(rm.playerViewY, 0, 0, 1);
      GL11.glTranslated(-d, -d, -d);
      	 */
      if (tile.isInWorld()) {
        double d = 0.5;
        GL11.glTranslated(d, d, d);

        double dx = tile.xCoord + 0.5 - RenderManager.renderPosX;
        double dy = tile.yCoord + 0.5 - RenderManager.renderPosY;
        double dz = tile.zCoord + 0.5 - RenderManager.renderPosZ;
        double[] angs = ReikaPhysicsHelper.cartesianToPolar(dx, dy, dz);
        GL11.glTranslated(-d, -d, -d);
        GL11.glRotated(angs[2], 0, 0, 1);
      }

      // GL11.glMatrixMode(GL11.GL_MODELVIEW);

      v5.startDrawingQuads();
      v5.setBrightness(240);
      int color =
          ReikaColorAPI.getColorWithBrightnessMultiplier(tile.getRenderColor(), alpha / 255F);
      v5.setColorRGBA_I(color, alpha);
      v5.addVertexWithUV(-1, -1, 0, u, v);
      v5.addVertexWithUV(1, -1, 0, du, v);
      v5.addVertexWithUV(1, 1, 0, du, dv);
      v5.addVertexWithUV(-1, 1, 0, u, dv);
      v5.draw();

      // GL11.glMatrixMode(GL11.GL_TEXTURE);
      // GL11.glPopMatrix();
      // GL11.glMatrixMode(GL11.GL_MODELVIEW);

      GL11.glPopMatrix();

      // }
    }

    double s = 0.5;
    GL11.glScaled(s, s, s);

    /*
    ReikaTextureHelper.bindTexture(ChromatiCraft.class, "Textures/Dimension Bump Maps/gray.png");

    u = 0;
    v = 0;
    du = 1;
    dv = 1;

    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPushMatrix();

    GL11.glRotated(angs[2], 0, 1, 0);
    GL11.glRotated(90-angs[1], 1, 0, 0);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);

    v5.startDrawingQuads();
    v5.setColorRGBA_I(this.getColor(), alpha);
    v5.addVertexWithUV(-1, -1, 0, u, v);
    v5.addVertexWithUV(1, -1, 0, du, v);
    v5.addVertexWithUV(1, 1, 0, du, dv);
    v5.addVertexWithUV(-1, 1, 0, u, dv);
    v5.draw();


    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
     */

    GL11.glPopMatrix();
  }