本文整理汇总了Java中net.minecraft.util.math.MathHelper.roundUpToPowerOfTwo方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.roundUpToPowerOfTwo方法的具体用法?Java MathHelper.roundUpToPowerOfTwo怎么用?Java MathHelper.roundUpToPowerOfTwo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.MathHelper
的用法示例。
在下文中一共展示了MathHelper.roundUpToPowerOfTwo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doStitch
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void doStitch()
{
Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]);
Arrays.sort((Object[])astitcher$holder);
net.minecraftforge.fml.common.ProgressManager.ProgressBar bar = net.minecraftforge.fml.common.ProgressManager.push("Texture stitching", astitcher$holder.length);
for (Stitcher.Holder stitcher$holder : astitcher$holder)
{
bar.step(stitcher$holder.getAtlasSprite().getIconName());
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())});
net.minecraftforge.fml.common.FMLLog.info(s);
for (Stitcher.Holder h : astitcher$holder)
net.minecraftforge.fml.common.FMLLog.info(" %s", h);
throw new StitcherException(stitcher$holder, s);
}
}
this.currentWidth = MathHelper.roundUpToPowerOfTwo(this.currentWidth);
this.currentHeight = MathHelper.roundUpToPowerOfTwo(this.currentHeight);
net.minecraftforge.fml.common.ProgressManager.pop(bar);
}
示例2: smallestEncompassingPowerOfTwo
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static int smallestEncompassingPowerOfTwo(int p_smallestEncompassingPowerOfTwo_0_)
{
return MathHelper.roundUpToPowerOfTwo(p_smallestEncompassingPowerOfTwo_0_);
}
示例3: expandAndAllocateSlot
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Expand stitched texture in order to make space for specified tile
*/
private boolean expandAndAllocateSlot(Stitcher.Holder p_94311_1_)
{
int i = Math.min(p_94311_1_.getWidth(), p_94311_1_.getHeight());
int j = Math.max(p_94311_1_.getWidth(), p_94311_1_.getHeight());
int k = MathHelper.roundUpToPowerOfTwo(this.currentWidth);
int l = MathHelper.roundUpToPowerOfTwo(this.currentHeight);
int i1 = MathHelper.roundUpToPowerOfTwo(this.currentWidth + i);
int j1 = MathHelper.roundUpToPowerOfTwo(this.currentHeight + i);
boolean flag1 = i1 <= this.maxWidth;
boolean flag2 = j1 <= this.maxHeight;
if (!flag1 && !flag2)
{
return false;
}
else
{
boolean flag3 = flag1 && k != i1;
boolean flag4 = flag2 && l != j1;
boolean flag;
if (flag3 ^ flag4)
{
flag = !flag3 && flag1; //Forge: Fix stitcher not expanding entire height before growing width, and {potentially} growing larger then the max size.
}
else
{
flag = flag1 && k <= l;
}
Stitcher.Slot stitcher$slot;
if (flag)
{
if (p_94311_1_.getWidth() > p_94311_1_.getHeight())
{
p_94311_1_.rotate();
}
if (this.currentHeight == 0)
{
this.currentHeight = p_94311_1_.getHeight();
}
stitcher$slot = new Stitcher.Slot(this.currentWidth, 0, p_94311_1_.getWidth(), this.currentHeight);
this.currentWidth += p_94311_1_.getWidth();
}
else
{
stitcher$slot = new Stitcher.Slot(0, this.currentHeight, this.currentWidth, p_94311_1_.getHeight());
this.currentHeight += p_94311_1_.getHeight();
}
stitcher$slot.addSlot(p_94311_1_);
this.stitchSlots.add(stitcher$slot);
return true;
}
}