Java Code Examples for net.minecraft.util.MathHelper.ceiling_double_int()

The following are Jave code examples for showing how to use ceiling_double_int() of the net.minecraft.util.MathHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BaseClient   File: ScaledResolution.java   Source Code and License Vote up 5 votes
public ScaledResolution(Minecraft p_i46445_1_)
{
    this.scaledWidth = p_i46445_1_.displayWidth;
    this.scaledHeight = p_i46445_1_.displayHeight;
    this.scaleFactor = 1;
    boolean flag = p_i46445_1_.isUnicode();
    int i = p_i46445_1_.gameSettings.guiScale;

    if (i == 0)
    {
        i = 1000;
    }

    while (this.scaleFactor < i && this.scaledWidth / (this.scaleFactor + 1) >= 320 && this.scaledHeight / (this.scaleFactor + 1) >= 240)
    {
        ++this.scaleFactor;
    }

    if (flag && this.scaleFactor % 2 != 0 && this.scaleFactor != 1)
    {
        --this.scaleFactor;
    }

    this.scaledWidthD = (double)this.scaledWidth / (double)this.scaleFactor;
    this.scaledHeightD = (double)this.scaledHeight / (double)this.scaleFactor;
    this.scaledWidth = MathHelper.ceiling_double_int(this.scaledWidthD);
    this.scaledHeight = MathHelper.ceiling_double_int(this.scaledHeightD);
}
 
Example 2
Project: BaseClient   File: ScaledResolution.java   Source Code and License Vote up 5 votes
public ScaledResolution(Minecraft p_i46445_1_)
{
    this.scaledWidth = p_i46445_1_.displayWidth;
    this.scaledHeight = p_i46445_1_.displayHeight;
    this.scaleFactor = 1;
    boolean flag = p_i46445_1_.isUnicode();
    int i = p_i46445_1_.gameSettings.guiScale;

    if (i == 0)
    {
        i = 1000;
    }

    while (this.scaleFactor < i && this.scaledWidth / (this.scaleFactor + 1) >= 320 && this.scaledHeight / (this.scaleFactor + 1) >= 240)
    {
        ++this.scaleFactor;
    }

    if (flag && this.scaleFactor % 2 != 0 && this.scaleFactor != 1)
    {
        --this.scaleFactor;
    }

    this.scaledWidthD = (double)this.scaledWidth / (double)this.scaleFactor;
    this.scaledHeightD = (double)this.scaledHeight / (double)this.scaleFactor;
    this.scaledWidth = MathHelper.ceiling_double_int(this.scaledWidthD);
    this.scaledHeight = MathHelper.ceiling_double_int(this.scaledHeightD);
}
 
Example 3
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static int ceil(double p_ceil_0_)
{
    return MathHelper.ceiling_double_int(p_ceil_0_);
}
 
Example 4
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static int ceil(double p_ceil_0_)
{
    return MathHelper.ceiling_double_int(p_ceil_0_);
}
 
Example 5
Project: SerenityCE   File: TTFFontRenderer.java   Source Code and License Vote up 4 votes
/**
 * Sets up the character data and textures.
 *
 * @param characterData The array of character data that should be filled.
 * @param type          The font type. (Regular, Bold, and Italics)
 */
private CharacterData[] setup(CharacterData[] characterData, int type) {
    // Quickly generates the colors.
    generateColors();

    // Changes the type of the font to the given type.
    Font font = this.font.deriveFont(type);

    // An image just to get font data.
    BufferedImage utilityImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);

    // The graphics of the utility image.
    Graphics2D utilityGraphics = (Graphics2D) utilityImage.getGraphics();

    // Sets the font of the utility image to the font.
    utilityGraphics.setFont(font);

    // The font metrics of the utility image.
    FontMetrics fontMetrics = utilityGraphics.getFontMetrics();

    // Iterates through all the characters in the character set of the font renderer.
    for (int index = 0; index < characterData.length; index++) {
        // The character at the current index.
        char character = (char) index;

        // The width and height of the character according to the font.
        Rectangle2D characterBounds = fontMetrics.getStringBounds(character + "", utilityGraphics);

        // The width of the character texture.
        float width = (float) characterBounds.getWidth() + (2 * MARGIN);

        // The height of the character texture.
        float height = (float) characterBounds.getHeight();

        // The image that the character will be rendered to.
        BufferedImage characterImage = new BufferedImage(MathHelper.ceiling_double_int(width), MathHelper.ceiling_double_int(height), BufferedImage.TYPE_INT_ARGB);

        // The graphics of the character image.
        Graphics2D graphics = (Graphics2D) characterImage.getGraphics();

        // Sets the font to the input font/
        graphics.setFont(font);

        // Sets the color to white with no alpha.
        graphics.setColor(new Color(255, 255, 255, 0));

        // Fills the entire image with the color above, makes it transparent.
        graphics.fillRect(0, 0, characterImage.getWidth(), characterImage.getHeight());

        // Sets the color to white to draw the character.
        graphics.setColor(Color.WHITE);

        // Enables anti-aliasing so the font doesn't have aliasing.
        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, this.fractionalMetrics ? RenderingHints.VALUE_FRACTIONALMETRICS_ON : RenderingHints.VALUE_FRACTIONALMETRICS_OFF);

        // Draws the character.
        graphics.drawString(character + "", MARGIN, fontMetrics.getAscent());

        // Generates a new texture id.
        int textureId = GlStateManager.generateTexture();

        // Allocates the texture in opengl.
        createTexture(textureId, characterImage);

        // Initiates the character data and stores it in the data array.
        characterData[index] = new CharacterData(character, characterImage.getWidth(), characterImage.getHeight(), textureId);
    }

    // Returns the filled character data array.
    return characterData;
}