Ejemplo n.º 1
0
 @Override
 public void drawBackground(int mouseX, int mouseY, float gameTicks) {
   glEnable(GL_BLEND);
   ApplyColor();
   super.drawBackground(mouseX, mouseY, gameTicks);
   drawIcon(stat.getIcon(level), posX + 3, posY + 3);
   if (direction != ForgeDirection.UNKNOWN) {
     glPushMatrix();
     glTranslated(posX, posY, 0);
     glTranslated(sizeX / 2, sizeY / 2, 0);
     glTranslated(direction.offsetX * (sizeX * 0.75), -direction.offsetY * (sizeY * 0.75), 0);
     if (direction == ForgeDirection.EAST) {
       glRotated(90, 0, 0, 1);
     } else if (direction == ForgeDirection.WEST) {
       glRotated(-90, 0, 0, 1);
     } else if (direction == ForgeDirection.DOWN) {
       glRotated(180, 0, 0, 1);
     }
     glTranslated(-3.5, -3.5, 0);
     ClientProxy.holoIcons.renderIcon("up_arrow", 0, 0);
     glPopMatrix();
   }
   ResetColor();
   glDisable(GL_BLEND);
 }
Ejemplo n.º 2
0
 private void rotateQuadBasedOnBlockRotation() {
   switch (this.direction) {
     case WEST:
       {
         GL11.glRotated(90, 0, 1, 0);
         break;
       }
     case SOUTH:
       {
         GL11.glRotated(180, 0, 1, 0);
         break;
       }
     case EAST:
       {
         GL11.glRotated(270, 0, 1, 0);
         break;
       }
     case UP:
       {
         GL11.glRotated(90, 1, 0, 0);
         break;
       }
     case DOWN:
       {
         GL11.glRotated(-90, 1, 0, 0);
         break;
       }
     case NORTH:
     case UNKNOWN:
     default:
       break;
   }
 }
  private void renderInnerFrame(TileEntityBiomePainter te, float par8) {
    GL11.glPushMatrix();
    double d = 0.5;
    // double ang = te.getTicksExisted()+par8;

    if (te.isInWorld()) {
      te.angX += te.rvX;
      te.angY += te.rvY;
      te.angZ += te.rvZ;

      double v = 0.375;
      te.rvX =
          v
              * (1 + 0.5 * Math.sin(Math.toRadians(te.getTicksExisted() + par8)))
              * (1 + 0.5 * Math.cos(Math.toRadians(90 + te.getTicksExisted() + par8)));
      te.rvY =
          v
              * (1 + 0.25 * Math.sin(Math.toRadians(2 * (te.getTicksExisted() + par8))))
              * (1 + 0.5 * Math.cos(Math.toRadians(te.getTicksExisted() + par8)));
      te.rvZ =
          v
              * (1 + 0.5 * Math.sin(Math.toRadians(90 + te.getTicksExisted() + par8)))
              * (1 + 0.25 * Math.cos(Math.toRadians(2 * (te.getTicksExisted() + par8))));

      GL11.glTranslated(d, d, d);
      GL11.glRotated(te.angX, 1, 0, 0);
      GL11.glRotated(te.angY, 0, 1, 0);
      GL11.glRotated(te.angZ, 0, 0, 1);
      GL11.glTranslated(-d, -d, -d);
    }
    GL11.glTranslated(0, -0.25, 0);
    this.renderModel(te, innerFrame, this.getTextureFolder() + "biomepainterinner.png");
    GL11.glPopMatrix();
  }
 private void renderTileMaterializationScannerAt(
     TileMaterializationScanner entity, double x, double y, double z, float partialRenderTick) {
   GL11.glPushMatrix();
   GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D);
   GL11.glRotated(180D, 0.0D, 0.0D, 1.0D);
   GL11.glRotated(90D * entity.getDirection() + 180, 0.0D, 1.0D, 0.0D);
   this.bindTexture(texture);
   this.model.render();
   GL11.glPopMatrix();
 }
  @Override
  public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) {
    TileEntityCustomizeableDecoration tile = (TileEntityCustomizeableDecoration) tileEntity;
    RenderElement[] renderElements = tile.getRenderElements();

    GL11.glPushMatrix();
    GL11.glColor4d(1, 1, 1, 1);
    GL11.glEnable(3042);
    GL11.glBlendFunc(770, 771);
    GL11.glTranslated(x, y, z);
    for (RenderElement element : renderElements) {
      if (element != null) {
        try {
          //					if(!GraphicUtilities.isModelPathValid(element.getModel())
          //						/*||*/if(	!GraphicUtilities.isTexturePathValid(element.getTexture()) )
          //						break;
          GL11.glPushMatrix();

          GraphicUtilities.bindTexture(element.getTexture());
          GL11.glColor4d(
              element.getColour()[0],
              element.getColour()[1],
              element.getColour()[2],
              element.getAlpha());
          GL11.glTranslated(0.5, 0.5, 0.5);
          GL11.glRotated(tile.getOrientation(), 0, 1, 0);
          GL11.glTranslated(-0.5, -0.5, -0.5);
          GL11.glTranslated(
              element.getTranslation()[0],
              element.getTranslation()[1],
              element.getTranslation()[2]);

          if (element.getRotation()[2] != 0) GL11.glRotated(element.getRotation()[2], 0, 0, 1);
          if (element.getRotation()[1] != 0) GL11.glRotated(element.getRotation()[1], 0, 1, 0);
          if (element.getRotation()[0] != 0) GL11.glRotated(element.getRotation()[0], 1, 0, 0);

          GL11.glScaled(tile.getScale(), tile.getScale(), tile.getScale());
          if (GraphicUtilities.isModelPathValid(element.getModel())) {
            IModelCustom tempMod = GraphicUtilities.bindModel(element.getModel());
            if (tempMod != null && GraphicUtilities.isModelPartValid(tempMod, element.getPart()))
              tempMod.renderPart(element.getPart());
          }
          GL11.glPopMatrix();
        } catch (Exception except) {
          // except.printStackTrace();
          GL11.glPopMatrix();
        }
      }
    }

    GL11.glDisable(3042);
    GL11.glColor4d(1, 1, 1, 1);
    GL11.glPopMatrix();
  }
  private void renderGlow(TileEntityBiomePainter te, float par8, int axis) {
    Tessellator v5 = Tessellator.instance;
    v5.setBrightness(240);
    int c =
        te.isInWorld()
            ? ReikaColorAPI.getModifiedHue(0xff0000, (te.getTicksExisted() * 2 + axis * 10) % 360)
            : 0xffffff;
    float r = ReikaColorAPI.getRed(c) / 255F;
    float g = ReikaColorAPI.getGreen(c) / 255F;
    float b = ReikaColorAPI.getBlue(c) / 255F;
    GL11.glColor4f(r, g, b, 1);
    GL11.glPushMatrix();
    double s = 0.5;
    GL11.glTranslated(0.5, 0, 0.5);
    GL11.glScaled(s, s, s);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    BlendMode.ADDITIVE.apply();
    double dy =
        te.isInWorld() ? 0.5 * Math.sin((te.getTicksExisted() + par8) / 12D + axis / 4D) : 0;
    if (axis >= 3) {
      dy = -dy;
    }
    double rx = 0;
    double ry = 0;
    double rz = 0;

    GL11.glPushMatrix();
    switch (axis) {
      case 0:
      case 3:
        GL11.glTranslated(0, dy, 0);
        GL11.glRotated(rx, 1, 0, 0);
        GL11.glRotated(ry, 0, 1, 0);
        GL11.glRotated(rz, 0, 0, 1);
        movingFrame.renderAll(te, null);
        break;
      case 1:
      case 4:
        GL11.glTranslated(dy, 0, 0);
        GL11.glRotated(rx, 1, 0, 0);
        GL11.glRotated(ry, 0, 1, 0);
        GL11.glRotated(rz, 0, 0, 1);
        movingFrame.renderAll(te, null);
        break;
      case 2:
      case 5:
        GL11.glTranslated(0, 0, dy);
        GL11.glRotated(rx, 1, 0, 0);
        GL11.glRotated(ry, 0, 1, 0);
        GL11.glRotated(rz, 0, 0, 1);
        movingFrame.renderAll(te, null);
        break;
    }
    GL11.glPopMatrix();

    GL11.glPopMatrix();
  }
  private void drawPlanetInfo(Planet planet) {
    glTranslated(0, planet.getSize() * 0.13f + 0.05f, 0);
    glScaled(0.005, 0.005, 0.005);
    glRotated(180, 0, 0, 1);
    if (GalaxyClient.getInstance().canSeePlanetInfo(planet, Minecraft.getMinecraft().thePlayer)) {
      int width = Minecraft.getMinecraft().fontRenderer.getStringWidth(planet.getName());
      Minecraft.getMinecraft()
          .fontRenderer
          .drawString(planet.getName(), -width / 2, 0, Planet.getGuiColor(planet).getColor());

      if (planet.isHomeworld(Minecraft.getMinecraft().thePlayer)) {
        width = Minecraft.getMinecraft().fontRenderer.getStringWidth("[Home]");
        Minecraft.getMinecraft()
            .fontRenderer
            .drawString(EnumChatFormatting.GOLD + "[Home]", -width / 2, -10, 0xFFFFFF);
      }
    } else {
      int width =
          Minecraft.getMinecraft().standardGalacticFontRenderer.getStringWidth(planet.getName());
      Minecraft.getMinecraft()
          .standardGalacticFontRenderer
          .drawString(planet.getName(), -width / 2, 0, Planet.getGuiColor(planet).getColor());

      if (planet.hasOwner()) {
        EntityPlayer owner = Minecraft.getMinecraft().theWorld.func_152378_a(planet.getOwnerUUID());
        if (owner != null) {
          String info = String.format("[%s]", owner.getDisplayName());
          width = Minecraft.getMinecraft().fontRenderer.getStringWidth(info);
          Minecraft.getMinecraft()
              .fontRenderer
              .drawString(EnumChatFormatting.GOLD + info, -width / 2, -10, 0xFFFFFF);
        }
      }
    }
  }
Ejemplo n.º 8
0
 public void draw() {
   glPushMatrix();
   DrawUtil.translate(offset);
   glRotated(rot, 0, 0, 1);
   img.draw();
   glPopMatrix();
 }
Ejemplo n.º 9
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);
  }
Ejemplo n.º 10
0
  protected void renderBeam(
      Vec3 from,
      Vec3 to,
      Vec3 offest,
      Color color,
      ResourceLocation texture,
      float tickness,
      T viewer) {
    if (texture != null) Minecraft.getMinecraft().renderEngine.bindTexture(texture);

    RenderUtils.applyColor(color);
    glDisable(GL_CULL_FACE);
    glEnable(GL_BLEND);
    glBlendFunc(GL_ONE, GL_ONE);
    glDisable(GL_LIGHTING);
    double distance = from.subtract(to).lengthVector();
    double v = -viewer.worldObj.getWorldTime() * 0.2;

    glPushMatrix();
    glTranslated(from.xCoord, from.yCoord, from.zCoord);
    glRotated(-viewer.getRotationYawHead(), 0, 1, 0);
    glRotated(viewer.rotationPitch, 1, 0, 0);
    glTranslated(offest.xCoord, offest.yCoord, offest.zCoord);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    t.addVertexWithUV(tickness, 0, 0, 0, v);
    t.addVertexWithUV(tickness, 0, distance, 0, v + distance * 1.5);
    t.addVertexWithUV(-tickness, 0, distance, 1, v + distance * 1.5);
    t.addVertexWithUV(-tickness, 0, 0, 1, v);

    t.addVertexWithUV(0, tickness, 0, 0, v);
    t.addVertexWithUV(0, tickness, distance, 0, v + distance * 1.5);
    t.addVertexWithUV(0, -tickness, distance, 1, v + distance * 1.5);
    t.addVertexWithUV(0, -tickness, 0, 1, v);
    t.draw();
    glPopMatrix();

    glEnable(GL_CULL_FACE);
    glDisable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  }
Ejemplo n.º 11
0
  @Override
  public void doRender(Entity var1, double x, double y, double z, float var8, float var9) {
    EntityCoinThrowing etc = (EntityCoinThrowing) var1;
    EntityPlayer player = etc.player;
    boolean fp =
        player == Minecraft.getMinecraft().thePlayer
            && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0;

    double dt = GameTimer.getTime() % 150;

    if (etc.player == null) return;
    // If syncedSingle and in client computer, do not render
    if (etc.isSync && player == Minecraft.getMinecraft().thePlayer) return;
    if (etc.posY < player.posY) return;
    GL11.glPushMatrix();
    {
      // x = player.posX - RenderManager.renderPosX;
      // y = etc.posY - RenderManager.renderPosY;
      // z = player.posZ - RenderManager.renderPosZ;
      if (player == Minecraft.getMinecraft().thePlayer) {
        x = z = 0;
      }

      GL11.glTranslated(x, y, z);
      if (fp) {
        GL11.glRotated(player.rotationYaw, 0, -1, 0);
      } else GL11.glRotated(player.renderYawOffset, 0, -1, 0);
      GL11.glTranslated(-0.63, -0.60, 0.30);
      float scale = 0.3F;
      GL11.glScalef(scale, scale, scale);
      GL11.glTranslated(0.5, 0.5, 0);
      GL11.glRotated((dt * 360.0 / 300.0), etc.axis.xCoord, etc.axis.yCoord, etc.axis.zCoord);
      GL11.glTranslated(-0.5, -0.5, 0);
      RenderUtils.drawEquippedItem(0.0625, Resources.TEX_COIN_FRONT, Resources.TEX_COIN_BACK);
    }
    GL11.glPopMatrix();
  }
Ejemplo n.º 12
0
  @Override
  public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    IRay ray = (IRay) ent;

    GL11.glPushMatrix();

    double length = ray.getLength();
    double fix = ray.getStartFix();

    Vec3 vo;
    if (ray.needsViewOptimize()) vo = ViewOptimize.getFixVector(ray);
    else vo = vec(0, 0, 0);
    // Rotate fix vector to world coordinate
    vo.rotateAroundY(MathUtils.toRadians(270 - ent.rotationYaw));

    Vec3 start = vec(0, 0, 0),
        end = add(start, multiply(new Motion3D(ent, true).getMotionVec(), length));
    start = add(start, vo);

    x += start.xCoord;
    y += start.yCoord;
    z += start.zCoord;

    Vec3 delta = subtract(end, start);
    double dxzsq = delta.xCoord * delta.xCoord + delta.zCoord * delta.zCoord;
    double npitch = MathUtils.toAngle(Math.atan2(delta.yCoord, Math.sqrt(dxzsq)));
    double nyaw = MathUtils.toAngle(Math.atan2(delta.xCoord, delta.zCoord));

    GL11.glTranslated(x, y, z);
    GL11.glRotated(-90 + nyaw, 0, 1, 0);
    GL11.glRotated(npitch, 0, 0, 1);
    GL11.glTranslated(fix, 0, 0);
    draw(ent, ray.getLength() - fix);

    GL11.glPopMatrix();
  }
Ejemplo n.º 13
0
  @Override
  public void render() {
    glLoadIdentity();
    glRotated(rotAngle, 0, 1, 0);
    glTranslated(pos.x, pos.y, pos.z);

    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_LINES);

    for (Line3D l : model.getLines()) {
      glColor3d(1.0, 0.5, 0.0);
      glVertex3d(l.start.x, l.start.y, l.start.z);
      glColor3d(1.0, 1.0, 1.0);
      glVertex3d(l.end.x, l.end.y, l.end.z);
    }
    glEnd();
  }
Ejemplo n.º 14
0
  public void render() {
    if (isAlive()) {

      // body
      Sprites.tubsBodyAnim.get(frame).bind();
      GL11.glPushMatrix();
      // GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glTranslated((x + bodyw / 2), (y + bodyh / 2), 0);
      GL11.glRotated(Math.toDegrees(angle), 0, 0, 1);
      GL11.glTranslated(-(x + bodyw / 2), -(y + bodyh / 2), 0);
      GL11.glBegin(GL11.GL_QUADS);
      GL11.glTexCoord2d(0, 0);
      GL11.glVertex2d(x, y);
      GL11.glTexCoord2d(1, 0);
      GL11.glVertex2d(x + bodyw, y);
      GL11.glTexCoord2d(1, 1);
      GL11.glVertex2d(x + bodyw, y + bodyh);
      GL11.glTexCoord2d(0, 1);
      GL11.glVertex2d(x, y + bodyh);
      GL11.glEnd();

      GL11.glDisable(GL11.GL_TEXTURE_2D);
      if (isHurt()) {
        GL11.glColor3d(0, 0, 0);
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2d(x, y - 3);
        GL11.glVertex2d(x - 1 + w, y - 3);
        GL11.glVertex2d(x + w, y - 3 - 3);
        GL11.glVertex2d(x - 1, y - 3 - 3);
        GL11.glEnd();
        GL11.glColor3d(0, 1, 0);
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2d(x, y - 3);
        GL11.glVertex2d(x - 1 + (health * w / maxHealth) + 2, y - 3);
        GL11.glVertex2d(x + (health * w / maxHealth) + 2, y - 3 - 3);
        GL11.glVertex2d(x - 1, y - 3 - 3);
        GL11.glEnd();
      }
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glColor3d(1, 1, 1);
      GL11.glPopMatrix();
    }
  }
  private void renderItemStack(TileEntity tileEntity, ItemStack itemStack) {

    GL11.glTranslated(0.5, 0, 0.5);
    if (itemStack.getItem() instanceof ItemBlock
        && RenderBlocks.renderItemIn3d(
            Block.getBlockFromItem(itemStack.getItem()).getRenderType())) {
      GL11.glTranslated(0, 0.55, 0);
    } else {
      GL11.glTranslated(0, 0.5, -(0.0625F * 3.65));
      GL11.glRotated(90, 1, 0, 0);
    }

    forceGraphics(true);

    EntityItem item = new EntityItem(tileEntity.getWorldObj(), 0, 0, 0, itemStack);
    item.getEntityItem().stackSize = 1;
    item.hoverStart = 0;

    RenderManager.instance.renderEntityWithPosYaw(item, 0, 0, 0, 0, 0);

    resetGraphics();
  }
Ejemplo n.º 16
0
  @ForgeSubscribe
  public void renderHealthBar(RenderLivingEvent.Specials.Post event) {
    if (!Debug.shouldRenderEntityHealthBars) return;

    if (event.entity == Minecraft.getMinecraft().thePlayer)
      return; // wont render the player hp in 3rd person
    float interp = timer.renderPartialTicks;
    EntityLivingBase e = event.entity;
    EntityPlayer p = Minecraft.getMinecraft().thePlayer;
    double diffX =
        e.prevPosX + interp * (e.posX - e.prevPosX) - (p.prevPosX + interp * (p.posX - p.prevPosX));
    double diffY =
        e.prevPosY + interp * (e.posY - e.prevPosY) - (p.prevPosY + interp * (p.posY - p.prevPosY));
    double diffZ =
        e.prevPosZ + interp * (e.posZ - e.prevPosZ) - (p.prevPosZ + interp * (p.posZ - p.prevPosZ));
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glPushMatrix();
    double height = e.height + 0.5;
    GL11.glTranslated(diffX, diffY + height, diffZ);
    GL11.glRotated(-(p.prevRotationYaw + interp * (p.rotationYaw - p.prevRotationYaw)), 0, 1, 0);
    GL11.glRotated(p.prevRotationPitch + interp * (p.rotationPitch - p.prevRotationPitch), 1, 0, 0);
    Tessellator t = Tessellator.instance;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    float currentHealth = e.getDataWatcher().func_111145_d(6);
    float maxHealth = e.func_110138_aP();
    if (event.entity instanceof EntityLivingBase) {

      GL11.glDisable(GL11.GL_DEPTH_TEST);
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      float f = 1.6F;
      float f1 = 0.016666668F * f;
      GL11.glScaled(-f1, -f1, f1);
      FontRenderer fr = Minecraft.getMinecraft().fontRenderer;

      float healthLength = fr.getStringWidth(e.getEntityName()) + 1;
      float healthHeight = -9f;

      float sizeOfActiveHealth = healthLength * (currentHealth / maxHealth);
      GL11.glPushMatrix();
      GL11.glTranslated(-healthLength / 2f, -1, 0);
      t.startDrawingQuads();
      t.setColorRGBA(100, 205, 100, 100);
      t.addVertexWithUV(0, 0, 0, 0, 0);
      t.addVertexWithUV(0, -healthHeight, 0, 0, 1);
      t.addVertexWithUV(sizeOfActiveHealth, -healthHeight, 0, 1, 1);
      t.addVertexWithUV(sizeOfActiveHealth, 0, 0, 1, 0);
      t.draw();
      float rest = healthLength - sizeOfActiveHealth;
      GL11.glTranslated(sizeOfActiveHealth, 0, 0);
      t.startDrawingQuads();
      t.setColorRGBA(255, 0, 0, 100);
      t.addVertexWithUV(0, 0, 0, 0, 0);
      t.addVertexWithUV(0, -healthHeight, 0, 0, 1);
      t.addVertexWithUV(rest, -healthHeight, 0, 1, 1);
      t.addVertexWithUV(rest, 0, 0, 1, 0);
      t.draw();

      GL11.glPopMatrix();
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      String text = e.getEntityName() + " [ " + currentHealth + "/" + maxHealth + " ]";
      fr.drawString(text, -fr.getStringWidth(text) / 2, 0, 553648127);
      GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);
  }
Ejemplo n.º 17
0
  @Override
  public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    switch (type) {
      case EQUIPPED:
        {
          GL11.glPushMatrix();
          GL11.glTranslatef(0.8f, 0.2f, 0.8f);
          GL11.glRotatef(135, 0.0f, 1.0f, 0.0f);
          GL11.glRotatef(-65, 0.0f, 0.0f, 1.0f);
          // GL11.glRotatef(-45, 1.0f, 0.0f, 0.0f);
          GL11.glScalef(0.09f, 0.09f, 0.09f);
          GL11.glShadeModel(GL11.GL_SMOOTH);
          model1.render();

          GL11.glTranslatef(12, 4, 0);
          glRotated(180, 1, 0, 0);
          drawLightningBolt((Entity) data[1]);
          GL11.glPopMatrix();

          break;
        }
      case EQUIPPED_FIRST_PERSON:
        {
          GL11.glPushMatrix();
          GL11.glTranslatef(0.9f, 0.5f, 0.9f);
          GL11.glRotatef(40, 0.0f, 1.0f, 0.0f);
          // GL11.glRotatef(-10, 0.0f, 0.0f, 1.0f);
          GL11.glScalef(0.09f, 0.09f, 0.09f);
          GL11.glShadeModel(GL11.GL_SMOOTH);
          model1.render();
          GL11.glPopMatrix();

          GL11.glPushMatrix();
          GL11.glRotatef(-40, 0.0f, 1.0f, 0.0f);

          GL11.glRotatef(90, 0.0f, 0.0f, 1.0f);
          GL11.glRotatef(90, 0.0f, 1.0f, 0.0f);
          GL11.glRotatef(-90, 1.0f, 0.0f, 0.0f);
          GL11.glRotatef(-10, 0.0f, 0.0f, 1.0f);
          GL11.glTranslatef(1.5f, -0.45f, -1.25f);

          GL11.glRotatef(-5, 0.0f, 1.0f, 0.0f);
          GL11.glRotatef(3.5f, 0.0f, 0.0f, 1.0f);
          GL11.glScalef(0.09f, 0.09f, 0.09f);
          GL11.glShadeModel(GL11.GL_SMOOTH);
          drawLightningBolt((Entity) data[1]);
          GL11.glPopMatrix();

          break;
        }
      case ENTITY:
        {
          GL11.glPushMatrix();
          GL11.glScalef(0.04f, 0.04f, 0.04f);
          GL11.glTranslatef(0f, 0f, 10.0f);
          GL11.glScalef(0.6f, 0.6f, 0.6f);
          GL11.glRotatef(90, 0.0f, 1.0f, 0.0f);
          GL11.glShadeModel(GL11.GL_SMOOTH);
          model1.render();
          GL11.glPopMatrix();
          break;
        }
      default:
        break;
    }
  }
  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();
  }
Ejemplo n.º 19
0
  @Override
  public void doRender(
      Entity ent, double x, double y, double z, float p_76986_8_, float partialTicks) {
    EntityGapingVoid egv = (EntityGapingVoid) ent;
    Minecraft mc = Minecraft.getMinecraft();
    mc.renderEngine.bindTexture(this.halo);
    Tessellator tess = Tessellator.instance;

    double age = egv.getAge() + partialTicks;

    setColour(age, 1.0);

    double scale = EntityGapingVoid.getVoidScale(age);

    double fullfadedist = 0.6 * scale;
    double fadedist = fullfadedist + 1.5;

    double halocoord = 0.58 * scale;
    double haloscaledist = 2.2 * scale;

    double dx = ent.posX - RenderManager.renderPosX;
    double dy = ent.posY - RenderManager.renderPosY;
    double dz = ent.posZ - RenderManager.renderPosZ;

    double xzlen = Math.sqrt(dx * dx + dz * dz);
    double len = Math.sqrt(dx * dx + dy * dy + dz * dz);

    if (len <= haloscaledist) {
      double close = (haloscaledist - len) / haloscaledist;
      halocoord *= 1.0 + close * close * close * close * 1.5;
    }

    double yang = Math.atan2(xzlen, dy) * ClientProxy.toDeg;
    double xang = Math.atan2(dx, dz) * ClientProxy.toDeg;

    // Lumberjack.info("dx: "+dx+", dy: "+dy+", dz: "+dz+", xang: "+xang);
    // Lumberjack.info("x: "+x+", y: "+y+", z: "+z);

    GL11.glDisable(GL11.GL_LIGHTING);
    mc.entityRenderer.disableLightmap(0.0);

    GL11.glPushMatrix();
    {
      GL11.glTranslated(x, y, z);

      GL11.glRotated(xang, 0, 1, 0);
      GL11.glRotated(yang + 90, 1, 0, 0);

      GL11.glPushMatrix();
      {
        GL11.glRotated(90, 1, 0, 0);

        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDepthMask(false);

        tess.startDrawingQuads();
        tess.addVertexWithUV(-halocoord, 0.0, -halocoord, 0.0, 0.0);
        tess.addVertexWithUV(-halocoord, 0.0, halocoord, 0.0, 1.0);
        tess.addVertexWithUV(halocoord, 0.0, halocoord, 1.0, 1.0);
        tess.addVertexWithUV(halocoord, 0.0, -halocoord, 1.0, 0.0);
        tess.draw();

        GL11.glDepthMask(true);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
      }
      GL11.glPopMatrix();

      Minecraft.getMinecraft().renderEngine.bindTexture(this.fill);

      GL11.glScaled(scale, scale, scale);

      model.renderAll();
    }
    GL11.glPopMatrix();

    if (len <= fadedist) {
      double alpha = 1.0;
      if (len >= fullfadedist) {
        alpha = 1.0 - ((len - fullfadedist) / (fadedist - fullfadedist));
        alpha = alpha * alpha * (3 - 2 * alpha);
      }
      setColour(age, alpha);
      GL11.glPushMatrix();
      {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_BLEND);

        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);

        double d = 0;

        tess.startDrawingQuads();
        tess.addVertexWithUV(-100, 100, d, 0.0, 0.0);
        tess.addVertexWithUV(-100, -100, d, 0.0, 1.0);
        tess.addVertexWithUV(100, -100, d, 1.0, 1.0);
        tess.addVertexWithUV(100, 100, d, 1.0, 0.0);
        tess.draw();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
      }
      GL11.glPopMatrix();
    }

    mc.entityRenderer.enableLightmap(0.0);
    GL11.glEnable(GL11.GL_LIGHTING);

    GL11.glColor4d(1, 1, 1, 1);
  }
  @Override
  public void renderBody(
      Galaxy galaxy,
      SpaceBody spaceBody,
      TileEntityMachineStarMap starMap,
      float partialTicks,
      float distance) {
    if (spaceBody instanceof Star) {

      Star star = (Star) spaceBody;
      random.setSeed(star.getSeed());

      double time = Minecraft.getMinecraft().theWorld.getWorldTime();

      glPushMatrix();
      glScaled(star.getSize(), star.getSize(), star.getSize());

      bindTexture(ClientProxy.renderHandler.getRenderParticlesHandler().getAdditiveTextureSheet());
      Tessellator.instance.startDrawingQuads();
      RenderUtils.tessalateParticle(
          Minecraft.getMinecraft().renderViewEntity,
          star_icon,
          star.getSize(),
          Vec3.createVectorHelper(0, 0, 0),
          Reference.COLOR_HOLO_YELLOW.getFloatR() * 0.1f,
          Reference.COLOR_HOLO_YELLOW.getFloatG() * 0.1f,
          Reference.COLOR_HOLO_YELLOW.getFloatB() * 0.1f,
          Reference.COLOR_HOLO_YELLOW.getFloatA() * 0.1f);
      Tessellator.instance.draw();

      RenderUtils.applyColorWithMultipy(new GuiColor(star.getColor()), 0.25f * (1f / distance));
      glPolygonMode(GL_FRONT, GL_LINE);
      glDisable(GL_TEXTURE_2D);
      double s = 0.9 + Math.sin(time * 0.01) * 0.1;
      glScaled(s, s, s);
      sphere_model.renderAll();
      glPolygonMode(GL_FRONT, GL_POINT);
      glPointSize(10 / (float) Math.max(0.1, distance));

      sphere_model.renderAll();
      if (Minecraft.getMinecraft().theWorld.getWorldTime() % 120 > 80) {
        double t = ((Minecraft.getMinecraft().theWorld.getWorldTime() % 120) - 80) / 40d;
        RenderUtils.applyColorWithMultipy(
            Reference.COLOR_HOLO_YELLOW, (float) MOMathHelper.easeIn(1 - t, 0, 0.1, 1));
        s = MOMathHelper.easeIn(t, 0.0, 10, 1);
        glScaled(1 + s, 1 + s, 1 + s);
        sphere_model.renderAll();
      }
      glPopMatrix();
      glPolygonMode(GL_FRONT, GL_LINE);

      int planetID = 0;
      for (Planet planet : star.getPlanets()) {
        float sizeMultiply = 1;
        if (starMap.getDestination().equals(planet)) {
          sizeMultiply = 1.2f;
        }

        glDisable(GL_ALPHA_TEST);
        GuiColor planetColor = Planet.getGuiColor(planet);
        random.setSeed(planet.getSeed());

        glPushMatrix();
        double axisRotation = random.nextInt(30) - 15;
        glRotated(axisRotation, 1, 0, 0);
        double radius = planet.getOrbit() * 2 + (star.getSize() / 2 + 0.1);
        float planetSize = planet.getSize();
        drawPlanetOrbit(planet, radius);

        glTranslated(
            Math.sin(time * 0.001 + 10 * planetID) * radius,
            0,
            Math.cos(time * 0.001 + 10 * planetID) * radius);

        glPolygonMode(GL_FRONT, GL_FILL);
        glEnable(GL_TEXTURE_2D);

        if (starMap.getDestination().equals(planet)) {
          bindTexture(
              ClientProxy.renderHandler.getRenderParticlesHandler().getAdditiveTextureSheet());
          Tessellator.instance.startDrawingQuads();
          RenderUtils.tessalateParticle(
              Minecraft.getMinecraft().renderViewEntity,
              selectedIcon,
              planet.getSize() * 0.15f * sizeMultiply,
              Vec3.createVectorHelper(0, 0, 0),
              planetColor);
          Tessellator.instance.draw();
        }

        if (starMap.getGalaxyPosition().equals(planet)) {
          bindTexture(
              ClientProxy.renderHandler.getRenderParticlesHandler().getAdditiveTextureSheet());
          Tessellator.instance.startDrawingQuads();
          RenderUtils.tessalateParticle(
              Minecraft.getMinecraft().renderViewEntity,
              currentIcon,
              planet.getSize() * 0.25f,
              Vec3.createVectorHelper(0, 0, 0),
              planetColor);
          Tessellator.instance.draw();
        }

        glPushMatrix();
        glRotated(-axisRotation, 1, 0, 0);
        RenderUtils.rotateTo(Minecraft.getMinecraft().renderViewEntity);
        drawPlanetInfo(planet);
        glPopMatrix();
        glPolygonMode(GL_FRONT, GL_LINE);
        glDisable(GL_TEXTURE_2D);

        RenderUtils.applyColorWithMultipy(planetColor, 0.3f * (1f / distance));
        glRotated(100, 1, 0, 0);
        glRotated(time * 2, 0, 0, 1);
        sphere.draw(
            planetSize * 0.1f * sizeMultiply,
            (int) (16 + planetSize * 2),
            (int) (8 + planetSize * 2));
        planetID++;
        glPopMatrix();
      }
      glEnable(GL_TEXTURE_2D);
      glPolygonMode(GL_FRONT, GL_FILL);
    }
  }
  @SubscribeEvent
  public void showOverlay(RenderGameOverlayEvent event) {
    ScaledResolution res = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    this.infobox = new Widget_Infobox(0, 20, 32, 32);
    this.poopbar = new Widget_PoopBar(0, 20, 32, 32);
    this.peebar = new Widget_Peebar(34, 20, 32, 32);
    this.infobox.text = "Hallo";

    int k = res.getScaledWidth();
    int l = res.getScaledHeight();
    int WaterLevelleft = res.getScaledWidth() / 2 + 81;

    if (event.type != ElementType.ALL) {
      return;
    }

    if (Minecraft.getMinecraft().currentScreen != null) {
      // return;
    }
    glPushMatrix();
    if (!Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode
        || Minecraft.getMinecraft().currentScreen instanceof GuiGamestart) {
      glEnable(GL_BLEND);
      glDepthMask(false);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      /*
       * mc.getTextureManager().bindTexture(temperatureGuiEmpty);
       * drawTexturedModalRect(0, 0, 0, 0, 17, 68);
       * mc.getTextureManager().bindTexture(temperatureGui);
       * drawTexturedModalRect(0, 64 - 64, 0, 64 - 64, 17, 68);
       */
      glEnable(GL12.GL_RESCALE_NORMAL);
      drawBars();
      int time = ((int) Minecraft.getMinecraft().thePlayer.worldObj.getWorldTime());
      int hours = time / 1200;
      int minutes = time / 20 - hours * 60;
      int seconds = time % 20;
      // drawString(Minecraft.getMinecraft().fontRendererObj,
      // String.valueOf("Time: "+ hours+":"+minutes+":"+seconds), 15, 15,
      // Color.white.getRGB());
      if (mc.thePlayer.ridingEntity != null && mc.thePlayer.ridingEntity instanceof EntityVehicle) {
        glPushMatrix();
        glPopMatrix();
      }

      glColor3f(1.0F, 1.0F, 1.0F);
      glDisable(GL_BLEND);
      glDepthMask(true);
      int numBottles = (int) (RLMPlayerProps.get(Minecraft.getMinecraft().thePlayer).WaterLevel);
      int offsetBottles =
          Minecraft.getMinecraft().thePlayer.isInsideOfMaterial(Material.water) ? 10 : 0;

      bindTexture(new ResourceLocation("reallifemod:textures/items/drop_Empty.png"));
      for (int i = 0; i < 10; i++) {
        drawScaledCustomSizeModalRect(
            (int) (WaterLevelleft + i * -8),
            res.getScaledHeight() - 48 - offsetBottles,
            0,
            0,
            8,
            8,
            8,
            8,
            8,
            8);
      }

      for (int i = 0; i < 10; i++) {
        if (i * 2 + 1 < numBottles) {
          bindTexture(new ResourceLocation("reallifemod:textures/items/drop_Full.png"));
          drawScaledCustomSizeModalRect(
              (int) (WaterLevelleft + i * -8),
              res.getScaledHeight() - 48 - offsetBottles,
              0,
              0,
              8,
              8,
              8,
              8,
              8,
              8);

        } else if (i * 2 + 1 == numBottles) {
          bindTexture(new ResourceLocation("reallifemod:textures/items/drop_Half.png"));
          drawScaledCustomSizeModalRect(
              (int) (WaterLevelleft + i * -8),
              res.getScaledHeight() - 48 - offsetBottles,
              0,
              0,
              8,
              8,
              8,
              8,
              8,
              8);
        }
      }

      if (RLMPlayerProps.get(Minecraft.getMinecraft().thePlayer).WaterLevel < 6
          && RLMPlayerProps.get(Minecraft.getMinecraft().thePlayer).WaterLevel > 3) {
        drawCenteredString(
            Minecraft.getMinecraft().fontRendererObj,
            LinesHelper.ThirstWarning.getChatComponentText_TextValue(),
            res.getScaledWidth() / 2,
            5,
            Color.white.getRGB());
      }

      if (RLMPlayerProps.get(Minecraft.getMinecraft().thePlayer).WaterLevel < 1
          && RLMPlayerProps.get(Minecraft.getMinecraft().thePlayer).WaterLevel > 0.1) {
        drawCenteredString(
            Minecraft.getMinecraft().fontRendererObj,
            LinesHelper.ThirstWarning2.getChatComponentText_TextValue(),
            res.getScaledWidth() / 2,
            5,
            Color.white.getRGB());
      }
    }

    if (Minecraft.getMinecraft().objectMouseOver != null) {
      BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
      if (Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem() != null
          && Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem().getItem()
              instanceof itemControlDevice) {
        if (Minecraft.getMinecraft().theWorld != null && pos != null) {
          if (Minecraft.getMinecraft().theWorld.getTileEntity(pos) instanceof TileEntity_Electric) {
            TileEntity_Electric t =
                (TileEntity_Electric) Minecraft.getMinecraft().theWorld.getTileEntity(pos);
            drawString(
                Minecraft.getMinecraft().fontRendererObj,
                "Current Voltage: " + t.clientVoltage,
                5,
                5,
                Color.white.getRGB());
            if (t.getTo() != null) {
              String s = t.getTo().getClass().getSimpleName();
              drawString(
                  Minecraft.getMinecraft().fontRendererObj,
                  "Gives energy to : "
                      + EnumChatFormatting.GREEN
                      + s
                      + " at: "
                      + t.getTo().getPos(),
                  5,
                  15,
                  Color.white.getRGB());
              if (!t.isPowerSource() && t.getFrom() != null) {
                String s2 = t.getFrom().getClass().getSimpleName();
                drawString(
                    Minecraft.getMinecraft().fontRendererObj,
                    "Gets energy from : "
                        + EnumChatFormatting.GREEN
                        + s2
                        + " at: "
                        + t.getFrom().getPos(),
                    5,
                    25,
                    Color.white.getRGB());
              }
            }
          }
        }
      }
    }

    /*
     * This is run when the player is driving a Car or Truck
     */
    if (Minecraft.getMinecraft().thePlayer.ridingEntity instanceof EntityDriveable) {
      EntityDriveable v = (EntityDriveable) Minecraft.getMinecraft().thePlayer.ridingEntity;
      bindTexture(new ResourceLocation("reallifemod:textures/gui/overlay/dashboard.png"));
      drawScaledCustomSizeModalRect(
          k - k / 5, (int) (l - k / 5), 0, 0, 512, 512, k / 5, k / 5, 512, 512);
      drawString(
          Minecraft.getMinecraft().fontRendererObj,
          String.valueOf("Driving a ") + v.getFile().vehicleName,
          5,
          5,
          Color.orange.getRGB());
      GL11.glPushMatrix();
      drawString(
          Minecraft.getMinecraft().fontRendererObj,
          String.valueOf(Math.round(v.motorspeed * 100) / 100 + " km/h"),
          k / 2 - 25,
          (int) (l - (l / 11.5)) - 7,
          Color.orange.getRGB());
      GL11.glPopMatrix();
      drawString(
          Minecraft.getMinecraft().fontRendererObj,
          String.valueOf("[Max Speed]: " + v.getFile().maxSpeed),
          5,
          25,
          Color.orange.getRGB());
      drawString(
          Minecraft.getMinecraft().fontRendererObj,
          String.valueOf("[Mass]: " + v.getFile().mass + " K"),
          5,
          35,
          Color.orange.getRGB());
      drawString(
          Minecraft.getMinecraft().fontRendererObj,
          String.valueOf("[Current throttle]: " + v.throttle + " m/s²"),
          5,
          45,
          Color.white.getRGB());

      double x = Math.sin(v.motorspeed + 100 * Math.PI / 180) * 10;
      double y = Math.cos(v.motorspeed + 100 * Math.PI / 180) * 10;
      GL11.glColor3f(1.0f, 1.0f, 1.0f);

      GL11.glPushMatrix();
      GL11.glTranslated(0, l - 80, 0);
      // bindTexture(new
      // ResourceLocation("reallifemod:textures/gui/overlay/dashboard.png"));
      // drawScaledCustomSizeModalRect(0, 10, 0, 0, 256, 256, l / 4, l /
      // 4, 256, 256);
      GL11.glPopMatrix();
      GL11.glPushMatrix();
      GL11.glTranslated(k - (k / 5) / 2, l - l / 5, 0);
      double scalefactor = 4.7058823529411764705882352941176D; // 1920/408/2
      // (/2=radius)
      double scale = (((2 * Math.PI) * ((k / 5 / 2) / k)));
      GL11.glRotated(12 + scale * v.actualspeed, 0, 0, 1);
      drawRect(-3, 10, 4, 1, Color.red.getRGB());
      drawRect(-2, 20, 3, 1, Color.red.getRGB());
      drawRect(-1, 35, 2, 1, Color.red.getRGB());
      drawRect(0, 50, 1, 1, Color.red.getRGB());

      GL11.glPopMatrix();

      GL11.glPushMatrix();
      GL11.glTranslated(k / 5.2, l - l / 10, 0);
      GL11.glRotated(270 - ((270 * Math.abs(v.throttle))), 0, 0, -1);
      drawRect(0, 25, 2, 1, Color.red.getRGB());
      GL11.glPopMatrix();

      // Steeringwheel
      int steeringWheelWidth = k / 2;
      float translatedX =
          (float)
              (-(Math.cos((v.steeringAngle * 0.0001) * Math.PI / 180) * steeringWheelWidth / 2));
      float translatedY =
          (float)
              (-(Math.cos((v.steeringAngle * 0.0001) * Math.PI / 180) * steeringWheelWidth / 2));

      GL11.glPushMatrix();
      // GL11.glScaled(0.75, 0.75, 0);
      GL11.glColor3f(1.0f, 1.0f, 1.0f);
      GL11.glTranslated(k * 9.5, l * 11 - 40, 0);
      GL11.glPushMatrix();
      GL11.glRotated((v.steeringAngle * 4), 0, 0, 1);
      GL11.glTranslated(translatedX, translatedY, 0);
      bindTexture(new ResourceLocation("reallifemod:textures/gui/overlay/steeringwheel.png"));
      drawScaledCustomSizeModalRect(
          0, 0, 0, 0, 256, 256, steeringWheelWidth, steeringWheelWidth, 256, 256);
      GL11.glPopMatrix();
      GL11.glPopMatrix();
    }

    if (Minecraft.getMinecraft().objectMouseOver.entityHit != null
        && Minecraft.getMinecraft().objectMouseOver.entityHit instanceof EntityDriveable) {
      EntityDriveable e = (EntityDriveable) Minecraft.getMinecraft().objectMouseOver.entityHit;
      drawCenteredString(
          Minecraft.getMinecraft().fontRendererObj,
          e.getFile().vehicleName,
          k / 2,
          l / 2 + 10,
          Color.orange.getRGB());
      drawCenteredString(
          Minecraft.getMinecraft().fontRendererObj,
          "Rightclick to mount!",
          k / 2,
          l / 2 + 20,
          Color.white.getRGB());

      GL11.glPushMatrix();
      // GL11.glTranslated(e.posX, e.posY, e.posZ);
      // Minecraft.getMinecraft().getRenderManager().getFontRenderer().drawString("Rightclick
      // to mount!", 0, 0, Color.white.getRGB());
      GL11.glPopMatrix();
      // drawCenteredString(Minecraft.getMinecraft().fontRendererObj,
      // "Press
      // '"+Keyboard.getKeyName(Keybindings.EnterVehicleKey.getKeyCode())+"'"+EnumChatFormatting.RESET+"to
      // mount!", k/2, l/2+20, Color.white.getRGB());
    }

    // infobox.drawWidget(0, 0, 0);

    glPopMatrix();
  }
  @Override
  public void renderTileEntityAt(
      TileEntity tile, double par2, double par4, double par6, float par8) {
    TileEntityPageExtractor te = (TileEntityPageExtractor) tile;
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glTranslated(par2, par4, par6);

    boolean hasBook = te.getStackInSlot(0) != null;
    double t = System.currentTimeMillis() / 10D;
    Tessellator v5 = Tessellator.instance;

    if (!te.isInWorld() || MinecraftForgeClient.getRenderPass() == 0) {
      GL11.glColor4f(1, 1, 1, 1);
      ReikaTextureHelper.bindTerrainTexture();
      v5.startDrawingQuads();
      v5.setBrightness(
          te.isInWorld()
              ? te.getBlockType()
                  .getMixedBrightnessForBlock(te.worldObj, te.xCoord, te.yCoord, te.zCoord)
              : 240);
      v5.setColorOpaque_I(0xffffff);
      IIcon ico = Blocks.stone_slab.getIcon(0, 0);
      double u = ico.getMinU();
      double v = ico.getMinV();
      double du = ico.getMaxU();
      double dv = ico.getMaxV();

      ico = Blocks.stone_slab.getIcon(2, 0);
      double u2 = ico.getMinU();
      double v2 = ico.getMinV();
      double du2 = ico.getMaxU();
      double dv2 = ico.getInterpolatedV(8);

      double h = 0.1875;
      double s = 0.375;

      v5.setNormal(0, 1, 0);
      v5.addVertexWithUV(0.5 - s, h, 0.5 + s, u, dv);
      v5.addVertexWithUV(0.5 + s, h, 0.5 + s, du, dv);
      v5.addVertexWithUV(0.5 + s, h, 0.5 - s, du, v);
      v5.addVertexWithUV(0.5 - s, h, 0.5 - s, u, v);

      v5.setColorOpaque_I(0xa0a0a0);
      v5.addVertexWithUV(1, 0, 0, u2, dv2);
      v5.addVertexWithUV(0.5 + s, h, 0.5 - s, u2, v2);
      v5.addVertexWithUV(0.5 + s, h, 0.5 + s, du2, v2);
      v5.addVertexWithUV(1, 0, 1, du2, dv2);

      v5.addVertexWithUV(0, 0, 1, u2, v2);
      v5.addVertexWithUV(0.5 - s, h, 0.5 + s, u2, dv2);
      v5.addVertexWithUV(0.5 - s, h, 0.5 - s, du2, dv2);
      v5.addVertexWithUV(0, 0, 0, du2, v2);

      v5.setColorOpaque_I(0x909090);
      v5.addVertexWithUV(1, 0, 1, u2, v2);
      v5.addVertexWithUV(0.5 + s, h, 0.5 + s, u2, dv2);
      v5.addVertexWithUV(0.5 - s, h, 0.5 + s, du2, dv2);
      v5.addVertexWithUV(0, 0, 1, du2, v2);

      v5.addVertexWithUV(0, 0, 0, u2, dv2);
      v5.addVertexWithUV(0.5 - s, h, 0.5 - s, u2, v2);
      v5.addVertexWithUV(0.5 + s, h, 0.5 - s, du2, v2);
      v5.addVertexWithUV(1, 0, 0, du2, dv2);

      v5.setColorOpaque_I(0x707070);
      v5.addVertexWithUV(0, 0, 0, u, v);
      v5.addVertexWithUV(1, 0, 0, du, v);
      v5.addVertexWithUV(1, 0, 1, du, dv);
      v5.addVertexWithUV(0, 0, 1, u, dv);
      v5.draw();

      if (hasBook) {
        GL11.glPushMatrix();
        GL11.glTranslated(0.5, 0.5, 0.5);
        GL11.glRotated(90, 0, 0, 1);
        double a = (t / 2D) % 360D;
        double da1 = 5 * Math.sin(t / 32D);
        double da2 = 8 * Math.cos(t / 48D);
        GL11.glRotated(a, 1, 0, 0);
        GL11.glRotated(da1, 0, 1, 0);
        GL11.glRotated(da2, 0, 0, 1);
        this.bindTexture(bookTex);
        book.render(null, 0, 0, 0, 1.05F, 0, 0.0625F);
        GL11.glPopMatrix();
      }
    }

    if (!te.isInWorld() || MinecraftForgeClient.getRenderPass() == 1) {

      GL11.glEnable(GL11.GL_BLEND);
      BlendMode.ADDITIVEDARK.apply();
      GL11.glDisable(GL11.GL_TEXTURE_2D);
      GL11.glDisable(GL11.GL_LIGHTING);
      GL11.glDisable(GL11.GL_ALPHA_TEST);
      GL11.glDepthMask(false);

      for (BasicVariablePoint point : points) {
        double r = 0.75 + 0.25 * Math.sin(t / 50D + Math.toRadians(point.hashCode() / 32D % 360D));
        DecimalPosition pos = point.asPosition();
        if (hasBook) {
          ChromaFX.renderBeam(
              0.5,
              0.5,
              0.5,
              0.5 + r * pos.xCoord,
              0.5 + r * pos.yCoord,
              0.5 + r * pos.zCoord,
              par8,
              255,
              0.125);
        } else {
          r /= 2;
        }
        if (te.isInWorld() && !Minecraft.getMinecraft().isGamePaused()) {
          EntityBlurFX fx =
              new EntityBlurFX(
                  te.worldObj,
                  te.xCoord + 0.5 + pos.xCoord * r,
                  te.yCoord + 0.5 + pos.yCoord * r,
                  te.zCoord + 0.5 + pos.zCoord * r);
          fx.setRapidExpand()
              .setScale(0.625F)
              .setLife(8)
              .setAlphaFading()
              .setIcon(ChromaIcons.FADE_GENTLE);
          Minecraft.getMinecraft().effectRenderer.addEffect(fx);
        }
        point.update();
      }

      GL11.glEnable(GL11.GL_TEXTURE_2D);
      ReikaTextureHelper.bindTerrainTexture();

      GL11.glTranslated(0.5, 0.5, 0.5);

      RenderManager rm = RenderManager.instance;
      if (te.isInWorld()) {
        GL11.glRotatef(-rm.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(rm.playerViewX, 1.0F, 0.0F, 0.0F);
      } else {
        GL11.glTranslated(0, 0.125, 0);
        GL11.glRotated(180 + 45, 0, 1, 0);
        GL11.glRotated(30, 1, 0, 0);
      }

      ChromaIcons[] icons =
          hasBook
              ? new ChromaIcons[] {
                ChromaIcons.HEXFLARE, ChromaIcons.BLURFLARE, ChromaIcons.RADIATE,
              }
              : new ChromaIcons[] {
                ChromaIcons.CONCENTRIC2REV, ChromaIcons.ROSES_WHITE,
              };

      for (int i = 0; i < icons.length; i++) {
        IIcon ico = icons[i].getIcon();

        double sb = hasBook ? 0.75 : 0.5;

        double s = sb - 0.1875 * i;

        double u = ico.getMinU();
        double v = ico.getMinV();
        double du = ico.getMaxU();
        double dv = ico.getMaxV();

        v5.startDrawingQuads();
        v5.setBrightness(240);
        v5.addVertexWithUV(-s, s, 0, u, dv);
        v5.addVertexWithUV(s, s, 0, du, dv);
        v5.addVertexWithUV(s, -s, 0, du, v);
        v5.addVertexWithUV(-s, -s, 0, u, v);
        v5.draw();
      }
    }

    GL11.glPopMatrix();
    GL11.glPopAttrib();
  }
  @Override
  public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float fl) {
    if (entity == null || !(entity instanceof TileBackpackStand)) return;
    int orientation =
        entity.getWorldObj().getBlockMetadata(entity.xCoord, entity.yCoord, entity.zCoord);
    int angle;
    switch (orientation) {
      case 2:
        angle = 0;
        break;
      case 3:
        angle = 180;
        break;
      case 4:
        angle = 90;
        break;
      case 5:
        angle = -90;
        break;
      default:
        angle = 0;
    }
    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y + 2.4, z + 0.5);
    GL11.glRotated(angle, 0, 1, 0);
    GL11.glRotated(180, 1, 0, 0);
    GL11.glScaled(10, 10, 10);
    ModelBackpackStand.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.01f);
    GL11.glPopMatrix();

    TileBackpackStand stand = (TileBackpackStand) entity;
    if (stand.inventory.getStackInSlot(0) == null) return;
    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y + 1.4, z + 0.5);
    GL11.glRotated(angle, 0, 1, 0);
    GL11.glRotated(180, 1, 0, 0);
    BackPackModel.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.1F);
    GL11.glPopMatrix();

    ItemStack bStack = stand.inventory.getStackInSlot(0);
    ItemKineticBackpack backpack = (ItemKineticBackpack) bStack.getItem();
    if (backpack.getInstalledCapsule(bStack, 0) != 0) {
      GL11.glPushMatrix();
      switch (orientation) {
        case 2:
          GL11.glTranslated(x + 0.7, y + 3.15, z + 0.07);
          break;
        case 3:
          GL11.glTranslated(x + 0.3, y + 3.15, z + 0.93);
          break;
        case 4:
          GL11.glTranslated(x + 0.07, y + 3.15, z + 0.3);
          break;
        case 5:
          GL11.glTranslated(x + 0.92, y + 3.15, z + 0.71);
          break;
      }
      GL11.glScaled(2, 2, 2);
      GL11.glRotated(angle, 0, 1, 0);
      GL11.glRotated(180, 1, 0, 0);
      ModelCapsule.INSTANCE.render(
          null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 0));
      GL11.glPopMatrix();
    }
    if (backpack.getInstalledCapsule(bStack, 1) != 0) {
      GL11.glPushMatrix();
      switch (orientation) {
        case 2:
          GL11.glTranslated(x + 0.3, y + 3.15, z + 0.07);
          break;
        case 3:
          GL11.glTranslated(x + 0.7, y + 3.15, z + 0.93);
          break;
        case 4:
          GL11.glTranslated(x + 0.08, y + 3.15, z + 0.69);
          break;
        case 5:
          GL11.glTranslated(x + 0.93, y + 3.15, z + 0.3);
          break;
      }
      GL11.glRotated(angle, 0, 1, 0);
      GL11.glScaled(2, 2, 2);
      GL11.glRotated(180, 1, 0, 0);
      ModelCapsule.INSTANCE.render(
          null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 1));
      GL11.glPopMatrix();
    }
    if (backpack.getInstalledCapsule(bStack, 2) != 0) {
      GL11.glPushMatrix();
      switch (orientation) {
        case 2:
          GL11.glTranslated(x + 0.7, y + 2.85, z + 0.07);
          break;
        case 3:
          GL11.glTranslated(x + 0.3, y + 2.85, z + 0.93);
          break;
        case 4:
          GL11.glTranslated(x + 0.07, y + 2.85, z + 0.3);
          break;
        case 5:
          GL11.glTranslated(x + 0.92, y + 2.85, z + 0.71);
          break;
      }

      GL11.glScaled(2, 2, 2);
      GL11.glRotated(angle, 0, 1, 0);
      GL11.glRotated(180, 1, 0, 0);
      ModelCapsule.INSTANCE.render(
          null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 2));
      GL11.glPopMatrix();
    }
    if (backpack.getInstalledCapsule(bStack, 3) != 0) {
      GL11.glPushMatrix();
      switch (orientation) {
        case 2:
          GL11.glTranslated(x + 0.3, y + 2.85, z + 0.07);
          break;
        case 3:
          GL11.glTranslated(x + 0.7, y + 2.85, z + 0.93);
          break;
        case 4:
          GL11.glTranslated(x + 0.07, y + 2.85, z + 0.71);
          break;
        case 5:
          GL11.glTranslated(x + 0.92, y + 2.85, z + 0.31);
          break;
      }
      GL11.glScaled(2, 2, 2);
      GL11.glRotated(angle, 0, 1, 0);
      GL11.glRotated(180, 1, 0, 0);
      ModelCapsule.INSTANCE.render(
          null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 3));
      GL11.glPopMatrix();
    }
  }
Ejemplo n.º 24
0
  public static void main(String[] args) {
    Window window = new Window(1280, 720, "Test", false);
    double rotAngle = 0;
    double X = 0;
    Cube cube = new Cube(0, 0, 0, 1);
    Logger log = Logger.getInstance();
    Axis axis = new Axis(0, 10, 0, 50);

    window.drawOn3D();
    // Cullface
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);

    // depth
    glEnable(GL_DEPTH_TEST);

    //
    glClearDepth(1.0f);
    glDepthFunc(GL_LEQUAL);
    //
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);

    while (!window.isCloseRequested()) {
      window.drawOn3D();
      // Clear the contents of the window (try disabling this and resizing the window � fun
      // guaranteed)
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

      // Polls the user input. This is very important, because it prevents your application from
      // becoming unresponsive
      glfwPollEvents();

      rotAngle = (glfwGetKey(window.getWindowID(), GLFW_KEY_RIGHT) == 1) ? rotAngle + 5 : rotAngle;
      rotAngle = (glfwGetKey(window.getWindowID(), GLFW_KEY_LEFT) == 1) ? rotAngle - 5 : rotAngle;

      X = (glfwGetKey(window.getWindowID(), GLFW_KEY_UP) == 1) ? X + .5 : X;
      X = (glfwGetKey(window.getWindowID(), GLFW_KEY_DOWN) == 1) ? X - .5 : X;

      log.debug("" + X);

      glPushMatrix();
      glTranslated(0, 0, -40 + X);
      //			glRotated(rotAngle, 0, 1, 0);

      axis.draw();
      glColor3d(0, 1, 1);
      glRotated(rotAngle, 0, 1, 0);
      cube.draw();
      glPopMatrix();

      window.drawOn2D();
      glPushMatrix();
      glColor3d(1, 1, 1);

      glBegin(GL_QUADS);
      glVertex2d(0, 0);
      glVertex2d(0, 100);
      glVertex2d(200, 100);
      glVertex2d(200, 0);
      glEnd();

      glPopMatrix();

      // Swaps the front and back framebuffers, this is a very technical process which you don't
      // necessarily
      // need to understand. You can simply see this method as updating the window contents.
      glfwSwapBuffers(window.getWindowID());
    }

    window.destroyWindow();
  }
  private void renderVehicle(
      EntityVehicle entity, double x, double y, double z, float p_76986_8_, float partialTicks) {
    VehicleFile f = entity.getFile();
    if (f == null) {
    } else {
      GL11.glPushMatrix();
      GL11.glDisable(GL11.GL_CULL_FACE);
      Minecraft.getMinecraft().renderEngine.bindTexture(f.texture);
      GL11.glTranslated(x, y, z);
      GL11.glRotated(-p_76986_8_ + 90, 0, 1, 0);
      GL11.glRotated(-entity.rotationPitch, 0, 0, 1);
      GlStateManager.pushMatrix();
      GL11.glPushMatrix();
      f.model.renderPart(f.modelName);
      GL11.glPopMatrix();
      // Rearaxis
      GL11.glPushMatrix();
      GL11.glTranslated(f.wheelPosBack.x, f.wheelPosBack.y, f.wheelPosBack.z + f.wheelPosLeft.z);
      GL11.glPushMatrix();
      GL11.glRotated(entity.wheelRotL, 0, 0, 1);
      f.model.renderPart(f.wheelsName);
      GL11.glPopMatrix();
      GL11.glTranslated(0, 0, -f.wheelPosLeft.z * 2);
      GL11.glRotated(180, 1, 0, 0);
      GL11.glRotated(-entity.wheelRotL, 0, 0, 1);
      f.model.renderPart(f.wheelsName);
      GL11.glPopMatrix();

      // Frontwheel L
      GL11.glPushMatrix();
      GL11.glTranslated(f.wheelPosLeft.x, f.wheelPosLeft.y, f.wheelPosLeft.z);
      GL11.glRotated(entity.steeringangle, 0, 1, 0);
      GL11.glRotated(entity.wheelRotL, 0, 0, 1);
      f.model.renderPart(f.wheelsName);
      GL11.glPopMatrix();

      // Frontwheel R
      GL11.glPushMatrix();
      GL11.glRotated(180, 1, 0, 0);
      GL11.glTranslated(f.wheelPosLeft.x, -f.wheelPosLeft.y, f.wheelPosLeft.z);
      GL11.glRotated(-entity.steeringangle, 0, 1, 0);
      GL11.glRotated(-entity.wheelRotL, 0, 0, 1);
      f.model.renderPart(f.wheelsName);
      GL11.glPopMatrix();
      GL11.glPushMatrix();
      GL11.glTranslated(f.steeringWheelPos.x, f.steeringWheelPos.y, f.steeringWheelPos.z);
      GL11.glPopMatrix();
      GL11.glEnable(GL11.GL_CULL_FACE);
      GlStateManager.enableBlend();
      if (f.transparentpartsname != null) {
        GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
        f.model.renderPart(f.transparentpartsname);
      }
      GlStateManager.disableBlend();
      GlStateManager.popMatrix();
      ;
      /*
       * GlStateManager.pushAttrib(); GlStateManager.pushMatrix();
       * WorldRenderer render =
       * Tessellator.getInstance().getWorldRenderer();
       * GlStateManager.disableLighting(); GL11.glBlendFunc(GL11.GL_ONE,
       * GL11.GL_ONE); render.startDrawing(GL11.GL_POLYGON);
       * render.setColorRGBA(255, 255, 0, 100); for (float i = 180f; i <
       * 360; i += 22.5) { render.setNormal((float)
       * Math.sin(Math.toRadians(i + 20)) * 10, (float) 0.01, (float)
       * Math.cos(Math.toRadians(i + 20)) * 10);
       * render.addVertex(Math.sin(Math.toRadians(i + 20)) * 10, 0.01,
       * Math.cos(Math.toRadians(i + 20)) * 10); }
       *
       * Tessellator.getInstance().draw();
       * GlStateManager.enableLighting(); GlStateManager.popMatrix();
       * GlStateManager.popAttrib();
       */
      GL11.glPopMatrix();
    }
  }