mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-27 07:23:08 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
addb2f92e1 | ||
|
|
b784769426 |
No files matched your search
@@ -26,7 +26,6 @@ import codechicken.nei.recipe.Recipe;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.recipe.RecipeInfo;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
|
||||
public class ItemCraftablesPanel
|
||||
extends AbstractSubpanel<ItemsGrid<ItemCraftablesPanel.CraftablesGridSlot, MouseContext>> {
|
||||
@@ -36,12 +35,15 @@ public class ItemCraftablesPanel
|
||||
protected final long realAmount;
|
||||
protected final boolean isFluidDisplay;
|
||||
protected final RecipeId recipeId;
|
||||
protected final ItemStack drawnItemStack;
|
||||
|
||||
public CraftablesGridSlot(int slotIndex, int itemIndex, ItemStack itemStack, RecipeId recipeId) {
|
||||
super(slotIndex, itemIndex, itemStack);
|
||||
this.realAmount = StackInfo.getAmount(itemStack);
|
||||
this.isFluidDisplay = StackInfo.isFluidDisplayItem(itemStack);
|
||||
this.recipeId = recipeId;
|
||||
final ItemStack empty = this.isFluidDisplay ? StackInfo.withAmount(itemStack, 0) : null;
|
||||
this.drawnItemStack = empty != null ? empty : itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,6 +51,11 @@ public class ItemCraftablesPanel
|
||||
return this.recipeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawItem(Rectangle4i rect) {
|
||||
super.drawItem(this.drawnItemStack, rect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <M extends MouseContext> void afterDraw(Rectangle4i rect, M mouseContext) {
|
||||
drawStackSize(rect);
|
||||
@@ -59,17 +66,7 @@ public class ItemCraftablesPanel
|
||||
|
||||
if (stackSize > 1) {
|
||||
final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
||||
String amountString = "";
|
||||
|
||||
if (stackSize < 10_000) {
|
||||
amountString = String.valueOf(stackSize);
|
||||
} else {
|
||||
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||
}
|
||||
|
||||
if (this.isFluidDisplay) {
|
||||
amountString += "L";
|
||||
}
|
||||
final String amountString = NEIClientUtils.formatSlotAmount(stackSize, this.isFluidDisplay);
|
||||
|
||||
NEIClientUtils.drawNEIOverlayText(
|
||||
amountString,
|
||||
|
||||
@@ -68,10 +68,9 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
protected void drawAmount(Rectangle4i rect, ItemStack stack, long amount) {
|
||||
final AmountText amountText = this.cache.computeIfAbsent(stack, key -> {
|
||||
final boolean isFluidDisplay = StackInfo.isFluidDisplayItem(key);
|
||||
final String text = formatAmount(key, amount);
|
||||
|
||||
return new AmountText(
|
||||
isFluidDisplay && !text.isEmpty() ? text + "L" : text,
|
||||
formatAmount(key, amount),
|
||||
isFluidDisplay ? Alignment.BottomLeft : Alignment.BottomRight);
|
||||
});
|
||||
|
||||
@@ -81,7 +80,7 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
||||
}
|
||||
|
||||
protected String formatAmount(ItemStack stack, long amount) {
|
||||
return amount == 0 ? "" : ReadableNumberConverter.INSTANCE.toWideReadableForm(amount);
|
||||
return amount == 0 ? "" : NEIClientUtils.formatSlotAmount(amount, StackInfo.isFluidDisplayItem(stack));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil;
|
||||
import com.gtnewhorizon.gtnhlib.util.numberformatting.options.CompactOptions;
|
||||
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.lib.inventory.InventoryRange;
|
||||
@@ -65,6 +66,7 @@ import codechicken.nei.api.ItemInfo;
|
||||
import codechicken.nei.recipe.GuiOverlayButton.ItemOverlayState;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.util.NEIKeyboardUtils;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
|
||||
public class NEIClientUtils extends NEIServerUtils {
|
||||
|
||||
@@ -154,6 +156,23 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
return getDecimalFormat().format(aNumber) + " L";
|
||||
}
|
||||
|
||||
/** Only loaded when GTNHLib is, since CompactOptions comes from it. */
|
||||
private static final class FluidSlotAmountFormat {
|
||||
|
||||
private static final CompactOptions OPTIONS = new CompactOptions().setCompactThreshold(10_000)
|
||||
.setDecimalPlaces(1).setRoundingMode(RoundingMode.DOWN);
|
||||
}
|
||||
|
||||
/** The amount drawn over a slot. Fluids use GTNHLib's compact formatting when it's loaded and have no unit. */
|
||||
public static String formatSlotAmount(long amount, boolean isFluid) {
|
||||
|
||||
if (isFluid && NEIModContainer.isGTNHLibLoaded()) {
|
||||
return NumberFormatUtil.formatNumberCompact(amount, FluidSlotAmountFormat.OPTIONS);
|
||||
}
|
||||
|
||||
return amount < 10_000 ? String.valueOf(amount) : ReadableNumberConverter.INSTANCE.toWideReadableForm(amount);
|
||||
}
|
||||
|
||||
public static String formatChance(float chance) {
|
||||
return CHANCE_FORMAT.format(chance);
|
||||
}
|
||||
|
||||
@@ -363,17 +363,7 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
||||
final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
||||
final long stackSize = this.bookmarkItem.getStackSize(amount);
|
||||
int color = 0xFFFFFF;
|
||||
String amountString = "";
|
||||
|
||||
if (stackSize < 10_000) {
|
||||
amountString = String.valueOf(stackSize);
|
||||
} else {
|
||||
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||
}
|
||||
|
||||
if (this.isFluidDisplay) {
|
||||
amountString += "L";
|
||||
}
|
||||
String amountString = NEIClientUtils.formatSlotAmount(stackSize, this.isFluidDisplay);
|
||||
|
||||
if (this.bookmarkItem.chance != PositionedStack.CHANCE_FULL) {
|
||||
amountString = "~" + amountString;
|
||||
|
||||
@@ -29,7 +29,6 @@ import codechicken.nei.drawable.DrawableResource;
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||
import codechicken.nei.scroll.GuiHelper;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
|
||||
class CraftingTreeCanvas {
|
||||
|
||||
@@ -409,12 +408,7 @@ class CraftingTreeCanvas {
|
||||
}
|
||||
|
||||
protected void drawStackSize(ItemTreeSlot node, long stackSize, int x, int y, boolean resolved) {
|
||||
String amountString = stackSize < 10_000 ? String.valueOf(stackSize)
|
||||
: ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||
|
||||
if (node.isFluidDisplay) {
|
||||
amountString += "L";
|
||||
}
|
||||
String amountString = NEIClientUtils.formatSlotAmount(stackSize, node.isFluidDisplay);
|
||||
|
||||
final boolean hasOutputChance = node.prefItem != null && node.prefItem.chance != PositionedStack.CHANCE_FULL;
|
||||
int color = 0xFFFFFF;
|
||||
|
||||
@@ -143,12 +143,7 @@ class StatsPanel extends ScrollContainer {
|
||||
}
|
||||
|
||||
private void drawStackSize() {
|
||||
String amountString = stackSize < 10_000 ? String.valueOf(stackSize)
|
||||
: ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||
|
||||
if (this.isFluidDisplay) {
|
||||
amountString += "L";
|
||||
}
|
||||
final String amountString = NEIClientUtils.formatSlotAmount(stackSize, this.isFluidDisplay);
|
||||
|
||||
NEIClientUtils.drawNEIOverlayText(
|
||||
amountString,
|
||||
|
||||
@@ -9,8 +9,8 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.item.FluidDrawer.FillDirection;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -48,14 +48,7 @@ public class FluidDisplayRenderer implements IItemRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
String amountString = "";
|
||||
|
||||
if (amount < 10_000) {
|
||||
amountString = String.valueOf(amount) + "L";
|
||||
} else {
|
||||
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(amount) + "L";
|
||||
}
|
||||
|
||||
final String amountString = NEIClientUtils.formatSlotAmount(amount, true);
|
||||
final FontRenderer fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||
float smallTextScale = fontRender.getUnicodeFlag() ? 3F / 4F : 1F / 2F;
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
|
||||
Reference in new issue
Block a user