mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-27 07:23:08 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7039052252 | ||
|
|
5a0ef18438 |
No files matched your search
@@ -192,9 +192,10 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
|||||||
builder = BookmarkItem.builder(groupId, itemStack, recipe, BookmarkItemType.RESULT).multiplier(1);
|
builder = BookmarkItem.builder(groupId, itemStack, recipe, BookmarkItemType.RESULT).multiplier(1);
|
||||||
} else if (recipeId != null) {
|
} else if (recipeId != null) {
|
||||||
builder = BookmarkItem.builder(groupId, itemStack).recipeId(recipeId)
|
builder = BookmarkItem.builder(groupId, itemStack).recipeId(recipeId)
|
||||||
.factor(StackInfo.getAmount(itemStack)).multiplier(1);
|
.factor(StackInfo.getAmountLong(itemStack)).multiplier(1);
|
||||||
} else {
|
} else {
|
||||||
builder = BookmarkItem.builder(groupId, itemStack).factor(1).multiplier(StackInfo.getAmount(itemStack));
|
builder = BookmarkItem.builder(groupId, itemStack).factor(1)
|
||||||
|
.multiplier(StackInfo.getAmountLong(itemStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existsRecipe) {
|
if (existsRecipe) {
|
||||||
@@ -261,7 +262,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
|||||||
builder = BookmarkItem.builder(groupId, stack, recipe, BookmarkItemType.RESULT);
|
builder = BookmarkItem.builder(groupId, stack, recipe, BookmarkItemType.RESULT);
|
||||||
} else {
|
} else {
|
||||||
builder = BookmarkItem.builder(groupId, stack).recipeId(recipeId)
|
builder = BookmarkItem.builder(groupId, stack).recipeId(recipeId)
|
||||||
.factor(StackInfo.getAmount(stack));
|
.factor(StackInfo.getAmountLong(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.grid.addItem(builder.multiplier(1).type(BookmarkItemType.ITEM).build(), true);
|
this.grid.addItem(builder.multiplier(1).type(BookmarkItemType.ITEM).build(), true);
|
||||||
@@ -553,7 +554,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
||||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
|
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import codechicken.nei.recipe.Recipe;
|
|||||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||||
import codechicken.nei.recipe.RecipeInfo;
|
import codechicken.nei.recipe.RecipeInfo;
|
||||||
import codechicken.nei.recipe.StackInfo;
|
import codechicken.nei.recipe.StackInfo;
|
||||||
|
import codechicken.nei.util.ReadableNumberConverter;
|
||||||
|
|
||||||
public class ItemCraftablesPanel
|
public class ItemCraftablesPanel
|
||||||
extends AbstractSubpanel<ItemsGrid<ItemCraftablesPanel.CraftablesGridSlot, MouseContext>> {
|
extends AbstractSubpanel<ItemsGrid<ItemCraftablesPanel.CraftablesGridSlot, MouseContext>> {
|
||||||
@@ -35,15 +36,12 @@ public class ItemCraftablesPanel
|
|||||||
protected final long realAmount;
|
protected final long realAmount;
|
||||||
protected final boolean isFluidDisplay;
|
protected final boolean isFluidDisplay;
|
||||||
protected final RecipeId recipeId;
|
protected final RecipeId recipeId;
|
||||||
protected final ItemStack drawnItemStack;
|
|
||||||
|
|
||||||
public CraftablesGridSlot(int slotIndex, int itemIndex, ItemStack itemStack, RecipeId recipeId) {
|
public CraftablesGridSlot(int slotIndex, int itemIndex, ItemStack itemStack, RecipeId recipeId) {
|
||||||
super(slotIndex, itemIndex, itemStack);
|
super(slotIndex, itemIndex, itemStack);
|
||||||
this.realAmount = StackInfo.getAmount(itemStack);
|
this.realAmount = StackInfo.getAmountLong(itemStack);
|
||||||
this.isFluidDisplay = StackInfo.isFluidDisplayItem(itemStack);
|
this.isFluidDisplay = StackInfo.isFluidDisplayItem(itemStack);
|
||||||
this.recipeId = recipeId;
|
this.recipeId = recipeId;
|
||||||
final ItemStack empty = this.isFluidDisplay ? StackInfo.withAmount(itemStack, 0) : null;
|
|
||||||
this.drawnItemStack = empty != null ? empty : itemStack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -51,11 +49,6 @@ public class ItemCraftablesPanel
|
|||||||
return this.recipeId;
|
return this.recipeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawItem(Rectangle4i rect) {
|
|
||||||
super.drawItem(this.drawnItemStack, rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <M extends MouseContext> void afterDraw(Rectangle4i rect, M mouseContext) {
|
public <M extends MouseContext> void afterDraw(Rectangle4i rect, M mouseContext) {
|
||||||
drawStackSize(rect);
|
drawStackSize(rect);
|
||||||
@@ -66,7 +59,17 @@ public class ItemCraftablesPanel
|
|||||||
|
|
||||||
if (stackSize > 1) {
|
if (stackSize > 1) {
|
||||||
final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
||||||
final String amountString = NEIClientUtils.formatSlotAmount(stackSize, this.isFluidDisplay);
|
String amountString = "";
|
||||||
|
|
||||||
|
if (stackSize < 10_000) {
|
||||||
|
amountString = String.valueOf(stackSize);
|
||||||
|
} else {
|
||||||
|
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isFluidDisplay) {
|
||||||
|
amountString += "L";
|
||||||
|
}
|
||||||
|
|
||||||
NEIClientUtils.drawNEIOverlayText(
|
NEIClientUtils.drawNEIOverlayText(
|
||||||
amountString,
|
amountString,
|
||||||
@@ -212,7 +215,7 @@ public class ItemCraftablesPanel
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
||||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
|
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -386,11 +389,11 @@ public class ItemCraftablesPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
final ItemStack stack = Recipe.getMainResult(results, pStack -> pStack.items[0]).item;
|
final ItemStack stack = Recipe.getMainResult(results, pStack -> pStack.items[0]).item;
|
||||||
int stackSize = 0;
|
long stackSize = 0;
|
||||||
|
|
||||||
for (PositionedStack result : results) {
|
for (PositionedStack result : results) {
|
||||||
if (containsSameType(result, stack)) {
|
if (containsSameType(result, stack)) {
|
||||||
stackSize += StackInfo.getAmount(result.item);
|
stackSize += StackInfo.getAmountLong(result.item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ItemStackAmount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void add(ItemStack item) {
|
public void add(ItemStack item) {
|
||||||
add(item, (long) StackInfo.getAmount(item));
|
add(item, StackInfo.getAmountLong(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(ItemStack stack, Long value) {
|
public void add(ItemStack stack, Long value) {
|
||||||
|
|||||||
@@ -68,9 +68,10 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
|||||||
protected void drawAmount(Rectangle4i rect, ItemStack stack, long amount) {
|
protected void drawAmount(Rectangle4i rect, ItemStack stack, long amount) {
|
||||||
final AmountText amountText = this.cache.computeIfAbsent(stack, key -> {
|
final AmountText amountText = this.cache.computeIfAbsent(stack, key -> {
|
||||||
final boolean isFluidDisplay = StackInfo.isFluidDisplayItem(key);
|
final boolean isFluidDisplay = StackInfo.isFluidDisplayItem(key);
|
||||||
|
final String text = formatAmount(key, amount);
|
||||||
|
|
||||||
return new AmountText(
|
return new AmountText(
|
||||||
formatAmount(key, amount),
|
isFluidDisplay && !text.isEmpty() ? text + "L" : text,
|
||||||
isFluidDisplay ? Alignment.BottomLeft : Alignment.BottomRight);
|
isFluidDisplay ? Alignment.BottomLeft : Alignment.BottomRight);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String formatAmount(ItemStack stack, long amount) {
|
protected String formatAmount(ItemStack stack, long amount) {
|
||||||
return amount == 0 ? "" : NEIClientUtils.formatSlotAmount(amount, StackInfo.isFluidDisplayItem(stack));
|
return amount == 0 ? "" : ReadableNumberConverter.INSTANCE.toWideReadableForm(amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ import org.lwjgl.opengl.GL11;
|
|||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil;
|
import com.gtnewhorizon.gtnhlib.util.numberformatting.NumberFormatUtil;
|
||||||
import com.gtnewhorizon.gtnhlib.util.numberformatting.options.CompactOptions;
|
|
||||||
|
|
||||||
import codechicken.lib.gui.GuiDraw;
|
import codechicken.lib.gui.GuiDraw;
|
||||||
import codechicken.lib.inventory.InventoryRange;
|
import codechicken.lib.inventory.InventoryRange;
|
||||||
@@ -66,7 +65,6 @@ import codechicken.nei.api.ItemInfo;
|
|||||||
import codechicken.nei.recipe.GuiOverlayButton.ItemOverlayState;
|
import codechicken.nei.recipe.GuiOverlayButton.ItemOverlayState;
|
||||||
import codechicken.nei.recipe.StackInfo;
|
import codechicken.nei.recipe.StackInfo;
|
||||||
import codechicken.nei.util.NEIKeyboardUtils;
|
import codechicken.nei.util.NEIKeyboardUtils;
|
||||||
import codechicken.nei.util.ReadableNumberConverter;
|
|
||||||
|
|
||||||
public class NEIClientUtils extends NEIServerUtils {
|
public class NEIClientUtils extends NEIServerUtils {
|
||||||
|
|
||||||
@@ -156,23 +154,6 @@ public class NEIClientUtils extends NEIServerUtils {
|
|||||||
return getDecimalFormat().format(aNumber) + " L";
|
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) {
|
public static String formatChance(float chance) {
|
||||||
return CHANCE_FORMAT.format(chance);
|
return CHANCE_FORMAT.format(chance);
|
||||||
}
|
}
|
||||||
@@ -331,7 +312,8 @@ public class NEIClientUtils extends NEIServerUtils {
|
|||||||
|
|
||||||
if (StackInfo.isFluidDisplayItem(stack.item)) {
|
if (StackInfo.isFluidDisplayItem(stack.item)) {
|
||||||
final FluidStack requiredFluid = StackInfo.getFluid(stack.item);
|
final FluidStack requiredFluid = StackInfo.getFluid(stack.item);
|
||||||
found = requiredFluid != null && consumeFluid(invStacks, remainingFluid, requiredFluid);
|
found = requiredFluid != null
|
||||||
|
&& consumeFluid(invStacks, remainingFluid, requiredFluid, StackInfo.getAmountLong(stack.item));
|
||||||
} else {
|
} else {
|
||||||
found = false;
|
found = false;
|
||||||
|
|
||||||
@@ -351,8 +333,8 @@ public class NEIClientUtils extends NEIServerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean consumeFluid(List<ItemStack> invStacks, Map<ItemStack, Long> remainingFluid,
|
private static boolean consumeFluid(List<ItemStack> invStacks, Map<ItemStack, Long> remainingFluid,
|
||||||
FluidStack requiredFluid) {
|
FluidStack requiredFluid, long requiredAmount) {
|
||||||
long need = requiredFluid.amount;
|
long need = requiredAmount;
|
||||||
final List<ItemStack> matched = new ArrayList<>();
|
final List<ItemStack> matched = new ArrayList<>();
|
||||||
|
|
||||||
for (ItemStack is : invStacks) {
|
for (ItemStack is : invStacks) {
|
||||||
@@ -383,7 +365,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
long remainingNeed = requiredFluid.amount;
|
long remainingNeed = requiredAmount;
|
||||||
for (ItemStack is : matched) {
|
for (ItemStack is : matched) {
|
||||||
final long available = remainingFluid.get(is);
|
final long available = remainingFluid.get(is);
|
||||||
final long consumed = Math.min(available, remainingNeed);
|
final long consumed = Math.min(available, remainingNeed);
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ public class PositionedStack implements Cloneable {
|
|||||||
/** The tank size the fill level is measured against, in mB. 0 means "always render full". */
|
/** The tank size the fill level is measured against, in mB. 0 means "always render full". */
|
||||||
protected int capacity = 0;
|
protected int capacity = 0;
|
||||||
protected boolean flowingTexture = false;
|
protected boolean flowingTexture = false;
|
||||||
|
protected boolean amountTooltip = true;
|
||||||
protected FillDirection fillDirection = FillDirection.AUTO;
|
protected FillDirection fillDirection = FillDirection.AUTO;
|
||||||
|
|
||||||
private ItemStack cachedFluidItem;
|
private ItemStack cachedFluidItem;
|
||||||
@@ -276,6 +277,15 @@ public class PositionedStack implements Cloneable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasAmountTooltip() {
|
||||||
|
return this.amountTooltip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Tank setAmountTooltip(boolean amountTooltip) {
|
||||||
|
this.amountTooltip = amountTooltip;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public FillDirection getFillDirection() {
|
public FillDirection getFillDirection() {
|
||||||
return this.fillDirection;
|
return this.fillDirection;
|
||||||
}
|
}
|
||||||
@@ -301,10 +311,11 @@ public class PositionedStack implements Cloneable {
|
|||||||
final List<String> customTooltip = super.getTooltip();
|
final List<String> customTooltip = super.getTooltip();
|
||||||
final FluidStack fluidStack = getFluidStack();
|
final FluidStack fluidStack = getFluidStack();
|
||||||
|
|
||||||
if (fluidStack != null && this.capacity > 0) {
|
if (fluidStack != null && this.amountTooltip) {
|
||||||
tooltip.add(
|
tooltip.add(
|
||||||
EnumChatFormatting.GRAY + NEIClientUtils
|
EnumChatFormatting.GRAY + NEIClientUtils.translate(
|
||||||
.translate("recipe.fluid.tank.amount", NEIClientUtils.formatFluid(fluidStack.amount)));
|
"recipe.fluid.tank.amount",
|
||||||
|
NEIClientUtils.formatFluid(StackInfo.getAmountLong(this.item))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customTooltip != null) {
|
if (customTooltip != null) {
|
||||||
|
|||||||
@@ -729,7 +729,7 @@ public abstract class ShortcutInputHandler {
|
|||||||
|
|
||||||
for (ItemStack stack : playerInventory) {
|
for (ItemStack stack : playerInventory) {
|
||||||
if (NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
if (NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
||||||
amount += StackInfo.getAmount(stack);
|
amount += StackInfo.getAmountLong(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,8 @@ public class BookmarkGridGenerator {
|
|||||||
|| group.crafting.calculatedItems.get(shadowIndex).calculatedType == CalculatedType.INGREDIENT;
|
|| group.crafting.calculatedItems.get(shadowIndex).calculatedType == CalculatedType.INGREDIENT;
|
||||||
|
|
||||||
final BookmarkItem shadowBookmarkItem = BookmarkItem.builder(bookmarkItem.groupId, bookmarkItem.itemStack)
|
final BookmarkItem shadowBookmarkItem = BookmarkItem.builder(bookmarkItem.groupId, bookmarkItem.itemStack)
|
||||||
.multiplier(1).factor(StackInfo.getAmount(bookmarkItem.itemStack)).recipeId(bookmarkItem.recipeId)
|
.multiplier(1).factor(StackInfo.getAmountLong(bookmarkItem.itemStack))
|
||||||
|
.recipeId(bookmarkItem.recipeId)
|
||||||
.type(isIngredient ? BookmarkItemType.INGREDIENT : BookmarkItemType.RESULT)
|
.type(isIngredient ? BookmarkItemType.INGREDIENT : BookmarkItemType.RESULT)
|
||||||
.permutations(Collections.emptyMap()).build();
|
.permutations(Collections.emptyMap()).build();
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class BookmarkItem {
|
|||||||
|
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
this.stack = stack;
|
this.stack = stack;
|
||||||
this.factor = StackInfo.isFluidDisplayItem(stack) ? Math.max(nbTag.getInteger("Count"), 1) : 1;
|
this.factor = StackInfo.isFluidDisplayItem(stack) ? Math.max(nbTag.getLong("Count"), 1) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder factor(long factor) {
|
public Builder factor(long factor) {
|
||||||
@@ -105,7 +105,7 @@ public class BookmarkItem {
|
|||||||
if (this.multiplier >= 0) {
|
if (this.multiplier >= 0) {
|
||||||
multiplier = this.multiplier;
|
multiplier = this.multiplier;
|
||||||
} else if (this.factor > 0) {
|
} else if (this.factor > 0) {
|
||||||
multiplier = StackInfo.getAmount(this.stack) / this.factor;
|
multiplier = StackInfo.getAmountLong(this.stack) / this.factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BookmarkItem(
|
return new BookmarkItem(
|
||||||
@@ -234,7 +234,7 @@ public class BookmarkItem {
|
|||||||
for (RecipeIngredient res : items) {
|
for (RecipeIngredient res : items) {
|
||||||
for (ItemStack perm : res.getPermutations()) {
|
for (ItemStack perm : res.getPermutations()) {
|
||||||
if (NEIClientUtils.areStacksSameTypeWithNBT(emptyStack, StackInfo.withAmount(perm, 0))) {
|
if (NEIClientUtils.areStacksSameTypeWithNBT(emptyStack, StackInfo.withAmount(perm, 0))) {
|
||||||
amount += 1L * StackInfo.getAmount(perm) * res.getChance();
|
amount += 1L * StackInfo.getAmountLong(perm) * res.getChance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,15 +271,15 @@ public class BookmarkItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.has("multiplier")) {
|
if (jsonObject.has("multiplier")) {
|
||||||
builder.multiplier(jsonObject.get("multiplier").getAsInt());
|
builder.multiplier(jsonObject.get("multiplier").getAsLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.has("factor")) {
|
if (jsonObject.has("factor")) {
|
||||||
builder.factor(jsonObject.get("factor").getAsInt());
|
builder.factor(jsonObject.get("factor").getAsLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.has("chance")) {
|
if (jsonObject.has("chance")) {
|
||||||
builder.chance(jsonObject.get("chance").getAsInt());
|
builder.chance(jsonObject.get("chance").getAsLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.get("recipeId") instanceof JsonObject recipeJson) {
|
if (jsonObject.get("recipeId") instanceof JsonObject recipeJson) {
|
||||||
@@ -320,8 +320,9 @@ public class BookmarkItem {
|
|||||||
final ItemStack newPerm = findPermutation(stack);
|
final ItemStack newPerm = findPermutation(stack);
|
||||||
|
|
||||||
if (oldPerm != null && newPerm != null) {
|
if (oldPerm != null && newPerm != null) {
|
||||||
final long oldAmount = StackInfo.getAmount(oldPerm);
|
final long oldAmount = StackInfo.getAmountLong(oldPerm);
|
||||||
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
|
final long amount = oldAmount > 0
|
||||||
|
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
|
||||||
: 0;
|
: 0;
|
||||||
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
||||||
: 1;
|
: 1;
|
||||||
@@ -369,8 +370,9 @@ public class BookmarkItem {
|
|||||||
final ItemStack newPerm = findPermutation(perm);
|
final ItemStack newPerm = findPermutation(perm);
|
||||||
|
|
||||||
if (oldPerm != null && newPerm != null) {
|
if (oldPerm != null && newPerm != null) {
|
||||||
final long oldAmount = StackInfo.getAmount(oldPerm);
|
final long oldAmount = StackInfo.getAmountLong(oldPerm);
|
||||||
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
|
final long amount = oldAmount > 0
|
||||||
|
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
|
||||||
: 0;
|
: 0;
|
||||||
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
||||||
: 1;
|
: 1;
|
||||||
|
|||||||
@@ -363,7 +363,17 @@ public class BookmarksGridSlot extends ItemsGridSlot {
|
|||||||
final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
final float panelFactor = (rect.w - 2) / (DEFAULT_SLOT_SIZE - 2);
|
||||||
final long stackSize = this.bookmarkItem.getStackSize(amount);
|
final long stackSize = this.bookmarkItem.getStackSize(amount);
|
||||||
int color = 0xFFFFFF;
|
int color = 0xFFFFFF;
|
||||||
String amountString = NEIClientUtils.formatSlotAmount(stackSize, this.isFluidDisplay);
|
String amountString = "";
|
||||||
|
|
||||||
|
if (stackSize < 10_000) {
|
||||||
|
amountString = String.valueOf(stackSize);
|
||||||
|
} else {
|
||||||
|
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isFluidDisplay) {
|
||||||
|
amountString += "L";
|
||||||
|
}
|
||||||
|
|
||||||
if (this.bookmarkItem.chance != PositionedStack.CHANCE_FULL) {
|
if (this.bookmarkItem.chance != PositionedStack.CHANCE_FULL) {
|
||||||
amountString = "~" + amountString;
|
amountString = "~" + amountString;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import codechicken.nei.drawable.DrawableResource;
|
|||||||
import codechicken.nei.guihook.GuiContainerManager;
|
import codechicken.nei.guihook.GuiContainerManager;
|
||||||
import codechicken.nei.recipe.Recipe.RecipeId;
|
import codechicken.nei.recipe.Recipe.RecipeId;
|
||||||
import codechicken.nei.scroll.GuiHelper;
|
import codechicken.nei.scroll.GuiHelper;
|
||||||
|
import codechicken.nei.util.ReadableNumberConverter;
|
||||||
|
|
||||||
class CraftingTreeCanvas {
|
class CraftingTreeCanvas {
|
||||||
|
|
||||||
@@ -408,7 +409,12 @@ class CraftingTreeCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void drawStackSize(ItemTreeSlot node, long stackSize, int x, int y, boolean resolved) {
|
protected void drawStackSize(ItemTreeSlot node, long stackSize, int x, int y, boolean resolved) {
|
||||||
String amountString = NEIClientUtils.formatSlotAmount(stackSize, node.isFluidDisplay);
|
String amountString = stackSize < 10_000 ? String.valueOf(stackSize)
|
||||||
|
: ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||||
|
|
||||||
|
if (node.isFluidDisplay) {
|
||||||
|
amountString += "L";
|
||||||
|
}
|
||||||
|
|
||||||
final boolean hasOutputChance = node.prefItem != null && node.prefItem.chance != PositionedStack.CHANCE_FULL;
|
final boolean hasOutputChance = node.prefItem != null && node.prefItem.chance != PositionedStack.CHANCE_FULL;
|
||||||
int color = 0xFFFFFF;
|
int color = 0xFFFFFF;
|
||||||
|
|||||||
@@ -143,7 +143,12 @@ class StatsPanel extends ScrollContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawStackSize() {
|
private void drawStackSize() {
|
||||||
final String amountString = NEIClientUtils.formatSlotAmount(stackSize, this.isFluidDisplay);
|
String amountString = stackSize < 10_000 ? String.valueOf(stackSize)
|
||||||
|
: ReadableNumberConverter.INSTANCE.toWideReadableForm(stackSize);
|
||||||
|
|
||||||
|
if (this.isFluidDisplay) {
|
||||||
|
amountString += "L";
|
||||||
|
}
|
||||||
|
|
||||||
NEIClientUtils.drawNEIOverlayText(
|
NEIClientUtils.drawNEIOverlayText(
|
||||||
amountString,
|
amountString,
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import codechicken.nei.NEIClientConfig;
|
|||||||
import codechicken.nei.NEIClientUtils;
|
import codechicken.nei.NEIClientUtils;
|
||||||
import codechicken.nei.NEIModContainer;
|
import codechicken.nei.NEIModContainer;
|
||||||
import codechicken.nei.recipe.StackInfo;
|
import codechicken.nei.recipe.StackInfo;
|
||||||
|
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||||
import codechicken.nei.util.ItemUntranslator;
|
import codechicken.nei.util.ItemUntranslator;
|
||||||
import codechicken.nei.util.ReadableNumberConverter;
|
import codechicken.nei.util.ReadableNumberConverter;
|
||||||
import codechicken.nei.util.RenderTooltipEventHelper;
|
import codechicken.nei.util.RenderTooltipEventHelper;
|
||||||
@@ -229,7 +230,9 @@ public class GuiContainerManager {
|
|||||||
public static String itemCountDetails(ItemStack stack) {
|
public static String itemCountDetails(ItemStack stack) {
|
||||||
final FluidStack fluid = StackInfo.getFluid(stack);
|
final FluidStack fluid = StackInfo.getFluid(stack);
|
||||||
if (fluid != null) {
|
if (fluid != null) {
|
||||||
return fluidAmountDetails(fluid.amount * Math.max(1, stack.stackSize));
|
// The fluid of a display item is limited to an int, its stored amount is not
|
||||||
|
final long amount = StackInfo.isFluidDisplayItem(stack) ? StackInfo.getAmountLong(stack) : fluid.amount;
|
||||||
|
return fluidAmountDetails(amount * Math.max(1, stack.stackSize));
|
||||||
} else {
|
} else {
|
||||||
return countDetails(
|
return countDetails(
|
||||||
stack.stackSize,
|
stack.stackSize,
|
||||||
@@ -243,17 +246,35 @@ public class GuiContainerManager {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String fluidAmountDetails(FluidStack fluid) {
|
public static String fluidAmountDetails(FluidStack fluid) {
|
||||||
return fluidAmountDetails(fluid.amount);
|
return fluidAmountDetails(GTFluidStackStringifyHandler.getFluidAmount(fluid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String fluidAmountDetails(int amount) {
|
public static String fluidAmountDetails(int amount) {
|
||||||
return countDetails(
|
return fluidAmountDetails((long) amount);
|
||||||
amount,
|
}
|
||||||
144,
|
|
||||||
translate("inventory.tooltip.count.fluid", "%s = %s * %s + %s"),
|
@Nullable
|
||||||
|
public static String fluidAmountDetails(long amount) {
|
||||||
|
if (amount <= 144) return null;
|
||||||
|
|
||||||
|
final long remainder = amount % 144;
|
||||||
|
final String units = NEIClientUtils.formatNumber(amount / 144);
|
||||||
|
|
||||||
|
if (remainder > 0) {
|
||||||
|
return String.format(
|
||||||
|
translate("inventory.tooltip.count.fluid", "%s = %s * %s + %s"),
|
||||||
|
NEIClientUtils.formatFluid(amount),
|
||||||
|
units,
|
||||||
|
NEIClientUtils.formatFluid(144),
|
||||||
|
NEIClientUtils.formatFluid(remainder));
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format(
|
||||||
translate("inventory.tooltip.count.fluid", "%s = %s * %s"),
|
translate("inventory.tooltip.count.fluid", "%s = %s * %s"),
|
||||||
NEIClientUtils::formatFluid);
|
NEIClientUtils.formatFluid(amount),
|
||||||
|
units,
|
||||||
|
NEIClientUtils.formatFluid(144));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import net.minecraftforge.fluids.FluidRegistry;
|
|||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import codechicken.nei.NEIClientUtils;
|
|
||||||
import codechicken.nei.item.FluidDrawer.FillDirection;
|
import codechicken.nei.item.FluidDrawer.FillDirection;
|
||||||
|
import codechicken.nei.util.ReadableNumberConverter;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@@ -48,7 +48,14 @@ public class FluidDisplayRenderer implements IItemRenderer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String amountString = NEIClientUtils.formatSlotAmount(amount, true);
|
String amountString = "";
|
||||||
|
|
||||||
|
if (amount < 10_000) {
|
||||||
|
amountString = String.valueOf(amount) + "L";
|
||||||
|
} else {
|
||||||
|
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(amount) + "L";
|
||||||
|
}
|
||||||
|
|
||||||
final FontRenderer fontRender = Minecraft.getMinecraft().fontRenderer;
|
final FontRenderer fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||||
float smallTextScale = fontRender.getUnicodeFlag() ? 3F / 4F : 1F / 2F;
|
float smallTextScale = fontRender.getUnicodeFlag() ? 3F / 4F : 1F / 2F;
|
||||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import net.minecraftforge.fluids.IFluidContainerItem;
|
|||||||
|
|
||||||
import codechicken.nei.NEIClientConfig;
|
import codechicken.nei.NEIClientConfig;
|
||||||
import codechicken.nei.NEIClientUtils;
|
import codechicken.nei.NEIClientUtils;
|
||||||
|
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@@ -46,7 +47,8 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack createStack(FluidStack fluidStack) {
|
public static ItemStack createStack(FluidStack fluidStack) {
|
||||||
return fluidStack == null ? null : createStack(fluidStack.getFluid(), fluidStack.amount);
|
return fluidStack == null ? null
|
||||||
|
: createStack(fluidStack.getFluid(), GTFluidStackStringifyHandler.getFluidAmount(fluidStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack createStack(Fluid fluid, long amount) {
|
public static ItemStack createStack(Fluid fluid, long amount) {
|
||||||
|
|||||||
@@ -487,11 +487,11 @@ public class Recipe {
|
|||||||
stack = getMainResult(getResults(), RecipeIngredient::getItemStack).getItemStack();
|
stack = getMainResult(getResults(), RecipeIngredient::getItemStack).getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
int stackSize = 0;
|
long stackSize = 0;
|
||||||
|
|
||||||
for (RecipeIngredient result : this.results) {
|
for (RecipeIngredient result : this.results) {
|
||||||
if (result.contains(stack)) {
|
if (result.contains(stack)) {
|
||||||
stackSize += result.getAmount();
|
stackSize += StackInfo.getAmountLong(result.getItemStack());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,9 +121,13 @@ public class StackInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getAmount(ItemStack stack) {
|
public static int getAmount(ItemStack stack) {
|
||||||
|
return (int) Math.min(getAmountLong(stack), Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getAmountLong(ItemStack stack) {
|
||||||
if (stack == null) return 0;
|
if (stack == null) return 0;
|
||||||
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
|
final NBTTagCompound nbTag = StackInfo.itemStackToNBT(stack);
|
||||||
return nbTag != null ? nbTag.getInteger("Count") : 0;
|
return nbTag != null ? nbTag.getLong("Count") : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT) {
|
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT) {
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
|
|||||||
for (ItemStack stack : items) {
|
for (ItemStack stack : items) {
|
||||||
if (stack != null
|
if (stack != null
|
||||||
&& NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
&& NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
|
||||||
amount += StackInfo.getAmount(stack);
|
amount += StackInfo.getAmountLong(stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
|||||||
|
|
||||||
protected static Class<?> itemFluidDisplay = null;
|
protected static Class<?> itemFluidDisplay = null;
|
||||||
protected static Method getFluidFromDisplayStack = null;
|
protected static Method getFluidFromDisplayStack = null;
|
||||||
|
private static Method getGTFluidAmount = null;
|
||||||
protected static Class<?> gtMetaGeneratedTool = null;
|
protected static Class<?> gtMetaGeneratedTool = null;
|
||||||
protected static Field playSound = null;
|
protected static Field playSound = null;
|
||||||
|
|
||||||
@@ -42,6 +43,12 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
|||||||
"gregtech.common.items.GT_FluidDisplayItem");
|
"gregtech.common.items.GT_FluidDisplayItem");
|
||||||
getFluidFromDisplayStack = gtUtility.getMethod("getFluidFromDisplayStack", ItemStack.class);
|
getFluidFromDisplayStack = gtUtility.getMethod("getFluidFromDisplayStack", ItemStack.class);
|
||||||
|
|
||||||
|
try {
|
||||||
|
getGTFluidAmount = gtUtility.getMethod("getFluidAmount", FluidStack.class);
|
||||||
|
} catch (NoSuchMethodException ignored) {
|
||||||
|
/* GregTech without long fluid stacks */
|
||||||
|
}
|
||||||
|
|
||||||
gtMetaGeneratedTool = ReflectionHelper.getClass(
|
gtMetaGeneratedTool = ReflectionHelper.getClass(
|
||||||
loader,
|
loader,
|
||||||
"gregtech.api.items.MetaGeneratedTool",
|
"gregtech.api.items.MetaGeneratedTool",
|
||||||
@@ -52,6 +59,18 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** GregTech fluid stacks can hold more than {@link FluidStack#amount} does */
|
||||||
|
public static long getFluidAmount(FluidStack fluidStack) {
|
||||||
|
|
||||||
|
if (getGTFluidAmount != null) {
|
||||||
|
try {
|
||||||
|
return (long) getGTFluidAmount.invoke(null, fluidStack);
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fluidStack.amount;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
|
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
|
||||||
|
|
||||||
@@ -61,7 +80,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
|||||||
if (fluidStack != null) {
|
if (fluidStack != null) {
|
||||||
final NBTTagCompound nbTag = new NBTTagCompound();
|
final NBTTagCompound nbTag = new NBTTagCompound();
|
||||||
nbTag.setString(FluidDisplayStackStringifyHandler.NBT_FLUID_NAME, fluidStack.getFluid().getName());
|
nbTag.setString(FluidDisplayStackStringifyHandler.NBT_FLUID_NAME, fluidStack.getFluid().getName());
|
||||||
nbTag.setInteger("Count", saveStackSize ? fluidStack.amount : 144);
|
nbTag.setLong("Count", saveStackSize ? getFluidAmount(fluidStack) : 144);
|
||||||
return nbTag;
|
return nbTag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ public class RecipeGroup {
|
|||||||
|
|
||||||
protected boolean isSameStack(ItemStack stackA, ItemStack stackB) {
|
protected boolean isSameStack(ItemStack stackA, ItemStack stackB) {
|
||||||
return stackA == stackB || NEIServerUtils.areStacksSameType(stackA, stackB)
|
return stackA == stackB || NEIServerUtils.areStacksSameType(stackA, stackB)
|
||||||
&& StackInfo.getAmount(stackA) == StackInfo.getAmount(stackB);
|
&& StackInfo.getAmountLong(stackA) == StackInfo.getAmountLong(stackB);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<ItemStack> getFilteredPermutations(int member, Point slotKey) {
|
protected List<ItemStack> getFilteredPermutations(int member, Point slotKey) {
|
||||||
|
|||||||
Reference in new issue
Block a user