mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 22:44:36 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6eaf200a1 |
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);
|
||||
} else if (recipeId != null) {
|
||||
builder = BookmarkItem.builder(groupId, itemStack).recipeId(recipeId)
|
||||
.factor(StackInfo.getAmount(itemStack)).multiplier(1);
|
||||
.factor(StackInfo.getAmountLong(itemStack)).multiplier(1);
|
||||
} 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) {
|
||||
@@ -261,7 +262,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
builder = BookmarkItem.builder(groupId, stack, recipe, BookmarkItemType.RESULT);
|
||||
} else {
|
||||
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);
|
||||
@@ -553,7 +554,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
|
||||
}
|
||||
|
||||
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class ItemCraftablesPanel
|
||||
|
||||
public CraftablesGridSlot(int slotIndex, int itemIndex, ItemStack itemStack, RecipeId recipeId) {
|
||||
super(slotIndex, itemIndex, itemStack);
|
||||
this.realAmount = StackInfo.getAmount(itemStack);
|
||||
this.realAmount = StackInfo.getAmountLong(itemStack);
|
||||
this.isFluidDisplay = StackInfo.isFluidDisplayItem(itemStack);
|
||||
this.recipeId = recipeId;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public class ItemCraftablesPanel
|
||||
|
||||
@Override
|
||||
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
|
||||
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -389,11 +389,11 @@ public class ItemCraftablesPanel
|
||||
}
|
||||
|
||||
final ItemStack stack = Recipe.getMainResult(results, pStack -> pStack.items[0]).item;
|
||||
int stackSize = 0;
|
||||
long stackSize = 0;
|
||||
|
||||
for (PositionedStack result : results) {
|
||||
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) {
|
||||
add(item, (long) StackInfo.getAmount(item));
|
||||
add(item, StackInfo.getAmountLong(item));
|
||||
}
|
||||
|
||||
public void add(ItemStack stack, Long value) {
|
||||
|
||||
@@ -312,7 +312,8 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
|
||||
if (StackInfo.isFluidDisplayItem(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 {
|
||||
found = false;
|
||||
|
||||
@@ -332,8 +333,8 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
}
|
||||
|
||||
private static boolean consumeFluid(List<ItemStack> invStacks, Map<ItemStack, Long> remainingFluid,
|
||||
FluidStack requiredFluid) {
|
||||
long need = requiredFluid.amount;
|
||||
FluidStack requiredFluid, long requiredAmount) {
|
||||
long need = requiredAmount;
|
||||
final List<ItemStack> matched = new ArrayList<>();
|
||||
|
||||
for (ItemStack is : invStacks) {
|
||||
@@ -364,7 +365,7 @@ public class NEIClientUtils extends NEIServerUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
long remainingNeed = requiredFluid.amount;
|
||||
long remainingNeed = requiredAmount;
|
||||
for (ItemStack is : matched) {
|
||||
final long available = remainingFluid.get(is);
|
||||
final long consumed = Math.min(available, remainingNeed);
|
||||
|
||||
@@ -303,8 +303,9 @@ public class PositionedStack implements Cloneable {
|
||||
|
||||
if (fluidStack != null && this.capacity > 0) {
|
||||
tooltip.add(
|
||||
EnumChatFormatting.GRAY + NEIClientUtils
|
||||
.translate("recipe.fluid.tank.amount", NEIClientUtils.formatFluid(fluidStack.amount)));
|
||||
EnumChatFormatting.GRAY + NEIClientUtils.translate(
|
||||
"recipe.fluid.tank.amount",
|
||||
NEIClientUtils.formatFluid(StackInfo.getAmountLong(this.item))));
|
||||
}
|
||||
|
||||
if (customTooltip != null) {
|
||||
|
||||
@@ -729,7 +729,7 @@ public abstract class ShortcutInputHandler {
|
||||
|
||||
for (ItemStack stack : playerInventory) {
|
||||
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;
|
||||
|
||||
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)
|
||||
.permutations(Collections.emptyMap()).build();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BookmarkItem {
|
||||
|
||||
this.groupId = groupId;
|
||||
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) {
|
||||
@@ -105,7 +105,7 @@ public class BookmarkItem {
|
||||
if (this.multiplier >= 0) {
|
||||
multiplier = this.multiplier;
|
||||
} else if (this.factor > 0) {
|
||||
multiplier = StackInfo.getAmount(this.stack) / this.factor;
|
||||
multiplier = StackInfo.getAmountLong(this.stack) / this.factor;
|
||||
}
|
||||
|
||||
return new BookmarkItem(
|
||||
@@ -234,7 +234,7 @@ public class BookmarkItem {
|
||||
for (RecipeIngredient res : items) {
|
||||
for (ItemStack perm : res.getPermutations()) {
|
||||
if (NEIClientUtils.areStacksSameTypeWithNBT(emptyStack, StackInfo.withAmount(perm, 0))) {
|
||||
amount += 1L * StackInfo.getAmount(perm) * res.getChance();
|
||||
amount += 1L * StackInfo.getAmountLong(perm) * res.getChance();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -271,15 +271,15 @@ public class BookmarkItem {
|
||||
}
|
||||
|
||||
if (jsonObject.has("multiplier")) {
|
||||
builder.multiplier(jsonObject.get("multiplier").getAsInt());
|
||||
builder.multiplier(jsonObject.get("multiplier").getAsLong());
|
||||
}
|
||||
|
||||
if (jsonObject.has("factor")) {
|
||||
builder.factor(jsonObject.get("factor").getAsInt());
|
||||
builder.factor(jsonObject.get("factor").getAsLong());
|
||||
}
|
||||
|
||||
if (jsonObject.has("chance")) {
|
||||
builder.chance(jsonObject.get("chance").getAsInt());
|
||||
builder.chance(jsonObject.get("chance").getAsLong());
|
||||
}
|
||||
|
||||
if (jsonObject.get("recipeId") instanceof JsonObject recipeJson) {
|
||||
@@ -320,8 +320,9 @@ public class BookmarkItem {
|
||||
final ItemStack newPerm = findPermutation(stack);
|
||||
|
||||
if (oldPerm != null && newPerm != null) {
|
||||
final long oldAmount = StackInfo.getAmount(oldPerm);
|
||||
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
|
||||
final long oldAmount = StackInfo.getAmountLong(oldPerm);
|
||||
final long amount = oldAmount > 0
|
||||
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
|
||||
: 0;
|
||||
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
||||
: 1;
|
||||
@@ -369,8 +370,9 @@ public class BookmarkItem {
|
||||
final ItemStack newPerm = findPermutation(perm);
|
||||
|
||||
if (oldPerm != null && newPerm != null) {
|
||||
final long oldAmount = StackInfo.getAmount(oldPerm);
|
||||
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
|
||||
final long oldAmount = StackInfo.getAmountLong(oldPerm);
|
||||
final long amount = oldAmount > 0
|
||||
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
|
||||
: 0;
|
||||
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
|
||||
: 1;
|
||||
|
||||
@@ -51,6 +51,7 @@ import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.NEIModContainer;
|
||||
import codechicken.nei.recipe.StackInfo;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
import codechicken.nei.util.ItemUntranslator;
|
||||
import codechicken.nei.util.ReadableNumberConverter;
|
||||
import codechicken.nei.util.RenderTooltipEventHelper;
|
||||
@@ -229,7 +230,9 @@ public class GuiContainerManager {
|
||||
public static String itemCountDetails(ItemStack stack) {
|
||||
final FluidStack fluid = StackInfo.getFluid(stack);
|
||||
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 {
|
||||
return countDetails(
|
||||
stack.stackSize,
|
||||
@@ -243,17 +246,35 @@ public class GuiContainerManager {
|
||||
@SuppressWarnings("unused")
|
||||
@Nullable
|
||||
public static String fluidAmountDetails(FluidStack fluid) {
|
||||
return fluidAmountDetails(fluid.amount);
|
||||
return fluidAmountDetails(GTFluidStackStringifyHandler.getFluidAmount(fluid));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String fluidAmountDetails(int amount) {
|
||||
return countDetails(
|
||||
amount,
|
||||
144,
|
||||
translate("inventory.tooltip.count.fluid", "%s = %s * %s + %s"),
|
||||
return fluidAmountDetails((long) amount);
|
||||
}
|
||||
|
||||
@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"),
|
||||
NEIClientUtils::formatFluid);
|
||||
NEIClientUtils.formatFluid(amount),
|
||||
units,
|
||||
NEIClientUtils.formatFluid(144));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -46,7 +47,8 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -487,11 +487,11 @@ public class Recipe {
|
||||
stack = getMainResult(getResults(), RecipeIngredient::getItemStack).getItemStack();
|
||||
}
|
||||
|
||||
int stackSize = 0;
|
||||
long stackSize = 0;
|
||||
|
||||
for (RecipeIngredient result : this.results) {
|
||||
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) {
|
||||
return (int) Math.min(getAmountLong(stack), Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static long getAmountLong(ItemStack stack) {
|
||||
if (stack == null) return 0;
|
||||
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) {
|
||||
|
||||
@@ -155,7 +155,7 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
|
||||
for (ItemStack stack : items) {
|
||||
if (stack != null
|
||||
&& 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 Method getFluidFromDisplayStack = null;
|
||||
private static Method getGTFluidAmount = null;
|
||||
protected static Class<?> gtMetaGeneratedTool = null;
|
||||
protected static Field playSound = null;
|
||||
|
||||
@@ -42,6 +43,12 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
"gregtech.common.items.GT_FluidDisplayItem");
|
||||
getFluidFromDisplayStack = gtUtility.getMethod("getFluidFromDisplayStack", ItemStack.class);
|
||||
|
||||
try {
|
||||
getGTFluidAmount = gtUtility.getMethod("getFluidAmount", FluidStack.class);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
/* GregTech without long fluid stacks */
|
||||
}
|
||||
|
||||
gtMetaGeneratedTool = ReflectionHelper.getClass(
|
||||
loader,
|
||||
"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
|
||||
public NBTTagCompound convertItemStackToNBT(ItemStack stack, boolean saveStackSize) {
|
||||
|
||||
@@ -61,7 +80,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
if (fluidStack != null) {
|
||||
final NBTTagCompound nbTag = new NBTTagCompound();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ public class RecipeGroup {
|
||||
|
||||
protected boolean isSameStack(ItemStack stackA, ItemStack 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) {
|
||||
|
||||
Reference in new issue
Block a user