コード例 #1
0
  private void drawIcon(ForgeDirection direction, float scale, ItemStack content) {
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glScalef(1.0F, 1.0F, -1.0F); // stops the item appearing inside out
    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); // rotates the item so it's not upside down

    translator.rotateTessellator(ForgeDirection.NORTH, direction, true);

    GL11.glScalef(scale, scale, scale); // shrinks the block down to the correct size
    GL11.glScalef(1.0F, 1.0F, 0.01F); // flattens the object by scaling Z to nothing

    DiscreteRenderHelper.renderItemFlatInWorld(content);
    GL11.glEnable(GL11.GL_LIGHTING);
  }
コード例 #2
0
  private void drawText(ForgeDirection direction, float scale, ItemStack content, int number) {
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glScalef(1.0F, 1.0F, -1.0F); // stops the item appearing inside out		
    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); // rotates the item so it's not upside down

    translator.rotateTessellator(ForgeDirection.NORTH, direction, false);

    String count = this.itemCountToStacks(content, number);
    int length = fontRenderer.getStringWidth(count);
    float middle = (length / 2 * scale) - (scale / 2);

    switch (direction) {
      case SOUTH:
        {
          GL11.glTranslated(-middle - 0.5, 0.0, -0.5);
          break;
        }

      case EAST:
        {
          GL11.glTranslated(-middle, 0.0, -0.5);

          break;
        }

      case WEST:
        {
          GL11.glTranslated(-middle - 0.5, 0, 0);
          break;
        }

      default:
        {
          GL11.glTranslated(-middle, 0, 0);
        }
    }

    GL11.glScalef(scale, scale, scale); // shrinks the text down to the correct size
    DiscreteRenderHelper.renderTextInWorld(count, 0, 0, 16777215, false);
    GL11.glEnable(GL11.GL_LIGHTING);
  }