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

The following are Jave code examples for showing how to use roundUpToPowerOfTwo() 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: DecompiledMinecraft   File: Stitcher.java   Source Code and License Vote up 6 votes
public void doStitch()
{
    Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]);
    Arrays.sort((Object[])astitcher$holder);

    for (Stitcher.Holder stitcher$holder : astitcher$holder)
    {
        if (!this.allocateSlot(stitcher$holder))
        {
            String s = String.format("Unable to fit: %s - size: %dx%d - Maybe try a lowerresolution resourcepack?", new Object[] {stitcher$holder.getAtlasSprite().getIconName(), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconWidth()), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconHeight())});
            throw new StitcherException(stitcher$holder, s);
        }
    }

    if (this.forcePowerOf2)
    {
        this.currentWidth = MathHelper.roundUpToPowerOfTwo(this.currentWidth);
        this.currentHeight = MathHelper.roundUpToPowerOfTwo(this.currentHeight);
    }
}
 
Example 2
Project: BaseClient   File: Stitcher.java   Source Code and License Vote up 6 votes
public void doStitch()
{
    Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])((Stitcher.Holder[])this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]));
    Arrays.sort((Object[])astitcher$holder);

    for (Stitcher.Holder stitcher$holder : astitcher$holder)
    {
        if (!this.allocateSlot(stitcher$holder))
        {
            String s = String.format("Unable to fit: %s, size: %dx%d, atlas: %dx%d, atlasMax: %dx%d - Maybe try a lower resolution resourcepack?", new Object[] {stitcher$holder.getAtlasSprite().getIconName(), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconWidth()), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconHeight()), Integer.valueOf(this.currentWidth), Integer.valueOf(this.currentHeight), Integer.valueOf(this.maxWidth), Integer.valueOf(this.maxHeight)});
            throw new StitcherException(stitcher$holder, s);
        }
    }

    if (this.forcePowerOf2)
    {
        this.currentWidth = MathHelper.roundUpToPowerOfTwo(this.currentWidth);
        this.currentHeight = MathHelper.roundUpToPowerOfTwo(this.currentHeight);
    }
}
 
Example 3
Project: BaseClient   File: TextureMap.java   Source Code and License Vote up 6 votes
private int detectMaxMipmapLevel(Map p_detectMaxMipmapLevel_1_, IResourceManager p_detectMaxMipmapLevel_2_)
{
    int i = this.detectMinimumSpriteSize(p_detectMaxMipmapLevel_1_, p_detectMaxMipmapLevel_2_, 20);

    if (i < 16)
    {
        i = 16;
    }

    i = MathHelper.roundUpToPowerOfTwo(i);

    if (i > 16)
    {
        Config.log("Sprite size: " + i);
    }

    int j = MathHelper.calculateLogBaseTwo(i);

    if (j < 4)
    {
        j = 4;
    }

    return j;
}
 
Example 4
Project: BaseClient   File: Stitcher.java   Source Code and License Vote up 6 votes
public void doStitch()
{
    Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])((Stitcher.Holder[])this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]));
    Arrays.sort((Object[])astitcher$holder);

    for (Stitcher.Holder stitcher$holder : astitcher$holder)
    {
        if (!this.allocateSlot(stitcher$holder))
        {
            String s = String.format("Unable to fit: %s, size: %dx%d, atlas: %dx%d, atlasMax: %dx%d - Maybe try a lower resolution resourcepack?", new Object[] {stitcher$holder.getAtlasSprite().getIconName(), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconWidth()), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconHeight()), Integer.valueOf(this.currentWidth), Integer.valueOf(this.currentHeight), Integer.valueOf(this.maxWidth), Integer.valueOf(this.maxHeight)});
            throw new StitcherException(stitcher$holder, s);
        }
    }

    if (this.forcePowerOf2)
    {
        this.currentWidth = MathHelper.roundUpToPowerOfTwo(this.currentWidth);
        this.currentHeight = MathHelper.roundUpToPowerOfTwo(this.currentHeight);
    }
}
 
Example 5
Project: BaseClient   File: TextureMap.java   Source Code and License Vote up 6 votes
private int detectMaxMipmapLevel(Map p_detectMaxMipmapLevel_1_, IResourceManager p_detectMaxMipmapLevel_2_)
{
    int i = this.detectMinimumSpriteSize(p_detectMaxMipmapLevel_1_, p_detectMaxMipmapLevel_2_, 20);

    if (i < 16)
    {
        i = 16;
    }

    i = MathHelper.roundUpToPowerOfTwo(i);

    if (i > 16)
    {
        Config.log("Sprite size: " + i);
    }

    int j = MathHelper.calculateLogBaseTwo(i);

    if (j < 4)
    {
        j = 4;
    }

    return j;
}
 
Example 6
Project: BaseClient   File: TextureUtils.java   Source Code and License Vote up 5 votes
public static BufferedImage scaleToPowerOfTwo(BufferedImage p_scaleToPowerOfTwo_0_, int p_scaleToPowerOfTwo_1_)
{
    if (p_scaleToPowerOfTwo_0_ == null)
    {
        return p_scaleToPowerOfTwo_0_;
    }
    else
    {
        int i = p_scaleToPowerOfTwo_0_.getWidth();
        int j = p_scaleToPowerOfTwo_0_.getHeight();
        int k = Math.max(i, p_scaleToPowerOfTwo_1_);
        k = MathHelper.roundUpToPowerOfTwo(k);

        if (k == i)
        {
            return p_scaleToPowerOfTwo_0_;
        }
        else
        {
            int l = j * k / i;
            BufferedImage bufferedimage = new BufferedImage(k, l, 2);
            Graphics2D graphics2d = bufferedimage.createGraphics();
            Object object = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;

            if (k % i != 0)
            {
                object = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
            }

            graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, object);
            graphics2d.drawImage(p_scaleToPowerOfTwo_0_, 0, 0, k, l, (ImageObserver)null);
            return bufferedimage;
        }
    }
}
 
Example 7
Project: BaseClient   File: TextureUtils.java   Source Code and License Vote up 5 votes
public static BufferedImage scaleToPowerOfTwo(BufferedImage p_scaleToPowerOfTwo_0_, int p_scaleToPowerOfTwo_1_)
{
    if (p_scaleToPowerOfTwo_0_ == null)
    {
        return p_scaleToPowerOfTwo_0_;
    }
    else
    {
        int i = p_scaleToPowerOfTwo_0_.getWidth();
        int j = p_scaleToPowerOfTwo_0_.getHeight();
        int k = Math.max(i, p_scaleToPowerOfTwo_1_);
        k = MathHelper.roundUpToPowerOfTwo(k);

        if (k == i)
        {
            return p_scaleToPowerOfTwo_0_;
        }
        else
        {
            int l = j * k / i;
            BufferedImage bufferedimage = new BufferedImage(k, l, 2);
            Graphics2D graphics2d = bufferedimage.createGraphics();
            Object object = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;

            if (k % i != 0)
            {
                object = RenderingHints.VALUE_INTERPOLATION_BILINEAR;
            }

            graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, object);
            graphics2d.drawImage(p_scaleToPowerOfTwo_0_, 0, 0, k, l, (ImageObserver)null);
            return bufferedimage;
        }
    }
}
 
Example 8
Project: DecompiledMinecraft   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static int smallestEncompassingPowerOfTwo(int p_smallestEncompassingPowerOfTwo_0_)
{
    return MathHelper.roundUpToPowerOfTwo(p_smallestEncompassingPowerOfTwo_0_);
}
 
Example 9
Project: BaseClient   File: TextureUtils.java   Source Code and License Vote up 4 votes
public static boolean isPowerOfTwo(int p_isPowerOfTwo_0_)
{
    int i = MathHelper.roundUpToPowerOfTwo(p_isPowerOfTwo_0_);
    return i == p_isPowerOfTwo_0_;
}
 
Example 10
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static int smallestEncompassingPowerOfTwo(int p_smallestEncompassingPowerOfTwo_0_)
{
    return MathHelper.roundUpToPowerOfTwo(p_smallestEncompassingPowerOfTwo_0_);
}
 
Example 11
Project: BaseClient   File: TextureUtils.java   Source Code and License Vote up 4 votes
public static boolean isPowerOfTwo(int p_isPowerOfTwo_0_)
{
    int i = MathHelper.roundUpToPowerOfTwo(p_isPowerOfTwo_0_);
    return i == p_isPowerOfTwo_0_;
}
 
Example 12
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static int smallestEncompassingPowerOfTwo(int p_smallestEncompassingPowerOfTwo_0_)
{
    return MathHelper.roundUpToPowerOfTwo(p_smallestEncompassingPowerOfTwo_0_);
}