Compare commits

..
Author SHA1 Message Date
boubou19andslprime 7fc80371c7 Copy fluid registry name instead of the display item id (#1122) (#1145)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:17:47 +01:00
f5f696abba Add NEI mob spawn overlay variants (#1111) (#1144)
Co-authored-by: OrderedSet86 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <[email protected]>
2026-11-19 08:15:31 +01:00
boubou19andslprime 277c32b9e6 Don't toggle handler info widget while typing in recipe search (#1121) (#1143)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:13:15 +01:00
boubou19andslprime fbb0cdc81a Add recipe text search with ~ prefix (#1120) (#1142)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:11:11 +01:00
boubou19andslprime 991e166e0a Speed up GUID cache and bookmark recipe lookups (#1119) (#1141)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:08:48 +01:00
d298c0e827 Don't copy stack unless it changed (#1116) (#1140)
Co-authored-by: DarkShadow44 <[email protected]>
Co-authored-by: slprime <[email protected]>
2026-11-19 08:06:32 +01:00
boubou19andslprime da16b40f36 Optimize GUI overlap scan for item panels (#1118) (#1139)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:02:56 +01:00
boubou19andslprime 651b59cba9 Fix WorldClient leak after leaving the world (#1115) (#1138)
Co-authored-by: slprime <[email protected]>
2026-11-19 08:00:50 +01:00
boubou19andslprime f922d7ef1e Make name optional in API.addCollapsibleGroup (#1114) (#1137)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:57:05 +01:00
boubou19andslprime 52ad6f38a5 Add API.addCollapsibleGroup for registering collapsible item groups (#1113) (#1136)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:52:58 +01:00
boubou19andslprime 8d118cb132 Rollback fluent setters in PositionedStack added in #1106 (#1110) (#1135)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:50:30 +01:00
boubou19andslprime 2590eec44a Fix NPE in StackInfo.getItemStackWithMinimumDamage for unregistered items (#1109) (#1134)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:48:46 +01:00
boubou19andslprime 81a92a28f5 Remove creative tab style option for recipe tabs (#1107) (#1133)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:46:47 +01:00
boubou19andslprime 621ab621c7 Move RecipeTransferRectHandler out of TemplateRecipeHandler and tidy up PositionedStack (#1106) (#1132)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:44:56 +01:00
boubou19andslprime 1aa4d56100 Add getResultStacks/getAuxiliaryStacks to IRecipeHandler (#1105) (#1131)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:42:56 +01:00
boubou19andslprime dc35985ea0 Stop auto-creating NEI config files, add export buttons instead (#1104) (#1130)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:40:46 +01:00
boubou19andslprime bb8632a012 Fix ConcurrentModificationException when iterating the crafting recipe list (#1103) (#1129)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:38:03 +01:00
b361604422 Remove per-world config override (#1094) (#1128)
Co-authored-by: slprime <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2026-11-19 07:35:55 +01:00
boubou19andslprime 02c97a05c3 Remove hardcoded vanilla block name overrides (#1102) (#1127)
Co-authored-by: slprime <[email protected]>
2026-11-19 07:33:11 +01:00
boubou19andArmisael5 d0785b5261 Add NEI Recipe Exporting (#1100) (#1126)
Co-authored-by: Armisael5 <[email protected]>
2026-11-19 07:31:13 +01:00
UltraProdigy 52ae4b2bd4 ci: run build and test on release branches 2026-11-09 01:11:41 -05:00
slprime acacd13bd9 Fix autocraft crash when started from the recipe screen (#1108) 2026-11-06 00:31:19 +02:00
35 changed files with 173 additions and 434 deletions

No files matched your search

@@ -192,10 +192,9 @@ 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.getAmountLong(itemStack)).multiplier(1);
.factor(StackInfo.getAmount(itemStack)).multiplier(1);
} else {
builder = BookmarkItem.builder(groupId, itemStack).factor(1)
.multiplier(StackInfo.getAmountLong(itemStack));
builder = BookmarkItem.builder(groupId, itemStack).factor(1).multiplier(StackInfo.getAmount(itemStack));
}
if (existsRecipe) {
@@ -262,7 +261,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.getAmountLong(stack));
.factor(StackInfo.getAmount(stack));
}
this.grid.addItem(builder.multiplier(1).type(BookmarkItemType.ITEM).build(), true);
@@ -554,7 +553,7 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
}
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
}
@Override
@@ -1074,7 +1073,6 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
}
this.grid.shiftGroupAmount(groupId, multiplier * shift);
clearTooltips();
return true;
}
}
@@ -1228,8 +1226,6 @@ public class BookmarkPanel extends PanelWidget<BookmarkGrid> {
if (helmStackIndex != -1) {
FastTransferManager.clickSlot(guiContainer, helmStackIndex, 0, 0);
}
clearTooltips();
}
}
@@ -18,6 +18,7 @@ import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.ItemsGrid.ItemsGridSlot;
import codechicken.nei.ItemsGrid.MouseContext;
import codechicken.nei.NEIClientUtils.Alignment;
import codechicken.nei.recipe.AutoCraftingManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.ICraftingHandler;
@@ -39,7 +40,7 @@ public class ItemCraftablesPanel
public CraftablesGridSlot(int slotIndex, int itemIndex, ItemStack itemStack, RecipeId recipeId) {
super(slotIndex, itemIndex, itemStack);
this.realAmount = StackInfo.getAmountLong(itemStack);
this.realAmount = StackInfo.getAmount(itemStack);
this.isFluidDisplay = StackInfo.isFluidDisplayItem(itemStack);
this.recipeId = recipeId;
}
@@ -215,7 +216,7 @@ public class ItemCraftablesPanel
@Override
protected ItemStack getDraggedStackWithQuantity(ItemStack itemStack) {
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmountLong(itemStack));
return ItemQuantityField.prepareStackWithQuantity(itemStack, StackInfo.getAmount(itemStack));
}
@Override
@@ -267,7 +268,7 @@ public class ItemCraftablesPanel
if (firstGui != null && !ItemCraftablesPanel.guiBlacklist.contains(firstGui.getClass().getName())) {
final boolean showOnlyFavorites = NEIClientConfig
.getBooleanSetting("inventory.craftables.favoritesOnly");
final ItemStackAmount inv = ItemStackAmount.of(firstGui);
final ItemStackAmount inv = AutoCraftingManager.getInventoryItems(firstGui);
if (this.lastGuiContainer != firstGui
|| showOnlyFavorites && this.lastFavoritesCount != FavoriteRecipes.size()
@@ -316,7 +317,7 @@ public class ItemCraftablesPanel
final Map<ItemStack, RecipeId> availableRecipes = new HashMap<>();
if (!availableHandlers.isEmpty()) {
final Map<Item, List<ItemStack>> invByItem = snapshot.inventory.groupByItem();
final Map<Item, List<ItemStack>> invByItem = indexInventoryByItem(snapshot.inventory.values());
if (snapshot.showOnlyFavorites) {
for (IRecipeHandler handler : availableHandlers) {
@@ -348,6 +349,16 @@ public class ItemCraftablesPanel
return availableHandlers;
}
private static Map<Item, List<ItemStack>> indexInventoryByItem(List<ItemStack> invStacks) {
final Map<Item, List<ItemStack>> index = new HashMap<>();
for (ItemStack stack : invStacks) {
index.computeIfAbsent(stack.getItem(), i -> new ArrayList<>()).add(stack);
}
return index;
}
private void collectHandlerCandidates(IRecipeHandler handler, Map<Item, List<ItemStack>> invByItem,
List<RecipeCandidate> candidates) {
IntStream.range(0, handler.numRecipes()).parallel().forEach(recipeIndex -> {
@@ -389,11 +400,11 @@ public class ItemCraftablesPanel
}
final ItemStack stack = Recipe.getMainResult(results, pStack -> pStack.items[0]).item;
long stackSize = 0;
int stackSize = 0;
for (PositionedStack result : results) {
if (containsSameType(result, stack)) {
stackSize += StackInfo.getAmountLong(result.item);
stackSize += StackInfo.getAmount(result.item);
}
}
@@ -437,8 +448,36 @@ public class ItemCraftablesPanel
return availableRecipes;
}
private static boolean existsIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> invByItem) {
return !ingredients.isEmpty() && NEIClientUtils.countMissingIngredients(ingredients, invByItem, 1) == 0;
private boolean existsIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> invByItem) {
final Map<ItemStack, Integer> usedItems = new HashMap<>();
for (PositionedStack pStack : ingredients) {
ItemStack used = null;
for (ItemStack permutation : pStack.items) {
final List<ItemStack> candidates = invByItem.get(permutation.getItem());
if (candidates == null) continue;
for (ItemStack is : candidates) {
if (usedItems.getOrDefault(is, is.stackSize) >= pStack.item.stackSize
&& NEIServerUtils.areStacksSameTypeCrafting(permutation, is)) {
used = is;
break;
}
}
if (used != null) break;
}
if (used != null) {
usedItems.put(used, usedItems.getOrDefault(used, used.stackSize) - pStack.item.stackSize);
} else {
return false;
}
}
return !usedItems.isEmpty();
}
}
@@ -1,17 +1,12 @@
package codechicken.nei;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -34,7 +29,7 @@ public class ItemStackAmount {
}
public void add(ItemStack item) {
add(item, StackInfo.getAmountLong(item));
add(item, (long) StackInfo.getAmount(item));
}
public void add(ItemStack stack, Long value) {
@@ -101,16 +96,6 @@ public class ItemStackAmount {
return list;
}
public Map<Item, List<ItemStack>> groupByItem() {
final Map<Item, List<ItemStack>> groups = new HashMap<>();
for (ItemStack stack : values()) {
groups.computeIfAbsent(stack.getItem(), i -> new ArrayList<>()).add(stack);
}
return groups;
}
public int size() {
return this.itemMap.size();
}
@@ -155,16 +140,4 @@ public class ItemStackAmount {
return result;
}
public static ItemStackAmount of(GuiContainer gui) {
final ItemStackAmount result = new ItemStackAmount();
for (Slot slot : gui.inventorySlots.inventorySlots) {
if (slot.getHasStack() && !(slot instanceof SlotCrafting) && slot.canTakeStack(gui.mc.thePlayer)) {
result.add(slot.getStack());
}
}
return result;
}
}
+17 -36
View File
@@ -5,7 +5,6 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.StringJoiner;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
@@ -31,9 +30,7 @@ public class KeyManager {
private static final Map<String, KeyBinding> keyBindings = new HashMap<>();
private static final Map<String, String> keyAliases = new HashMap<>();
private static volatile boolean pendingOptionsReload = false;
private static final int NO_INPUT_EVENT = Integer.MIN_VALUE;
private static int currentEvent = NO_INPUT_EVENT;
private static int clickedButton = -1;
static {
// Aliases for legacy keybinds
@@ -73,22 +70,16 @@ public class KeyManager {
public static boolean isKeyDown(String ident) {
final KeyBinding binding = getKeyBinding(ident);
if (binding == null) {
return false;
}
final int keyCode = binding.getKeyCode();
if (currentEvent != NO_INPUT_EVENT) {
return keyCode == currentEvent;
}
if (binding != null) {
final int keyCode = binding.getKeyCode();
if (keyCode < 0) {
final int button = keyCode + 100;
return Mouse.isButtonDown(button);
}
if (keyCode > Keyboard.KEY_NONE && keyCode < Keyboard.KEYBOARD_SIZE) {
return Keyboard.isKeyDown(keyCode);
if (keyCode < 0) {
final int button = keyCode + 100;
return Mouse.isButtonDown(button) || button == clickedButton;
} else if (keyCode > Keyboard.KEY_NONE && keyCode < Keyboard.KEYBOARD_SIZE) {
return Keyboard.isKeyDown(keyCode);
}
}
return false;
@@ -106,23 +97,6 @@ public class KeyManager {
return false;
}
private static <T> T withEvent(int code, Supplier<T> handler) {
final int previous = currentEvent;
currentEvent = code;
try {
return handler.get();
} finally {
currentEvent = previous;
}
}
public static void handleKeyEvent(int keyCode, Runnable handler) {
withEvent(keyCode, () -> {
handler.run();
return null;
});
}
/**
* Runs a hotkey handler for a click of the given mouse button if the button is bound to any NEI key binding. The
* button is reported as down by {@link #isKeyDown} for the duration of the call, because the LWJGL button state can
@@ -135,7 +109,14 @@ public class KeyManager {
return false;
}
return withEvent(button - 100, handler::getAsBoolean);
final int previous = clickedButton;
clickedButton = button;
try {
return handler.getAsBoolean();
} finally {
clickedButton = previous;
}
}
public static boolean isHashDown(String ident) {
@@ -713,8 +713,6 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
@Override
public void load(GuiContainer gui) {
NEIController.load(gui);
if (isEnabled()) {
setInputFocused(null);
@@ -728,6 +726,8 @@ public class LayoutManager implements IContainerInputHandler, IContainerTooltipH
AutoFocusWidget.instance.load(gui);
}
NEIController.load(gui);
if (checkCreativeInv(gui) && gui.mc.currentScreen instanceof GuiContainerCreative) // override creative with
// creative+
gui.mc.displayGuiScreen(null); // close the screen and wait for the server to open it for us
@@ -312,8 +312,7 @@ public class NEIClientUtils extends NEIServerUtils {
if (StackInfo.isFluidDisplayItem(stack.item)) {
final FluidStack requiredFluid = StackInfo.getFluid(stack.item);
found = requiredFluid != null
&& consumeFluid(invStacks, remainingFluid, requiredFluid, StackInfo.getAmountLong(stack.item));
found = requiredFluid != null && consumeFluid(invStacks, remainingFluid, requiredFluid);
} else {
found = false;
@@ -333,8 +332,8 @@ public class NEIClientUtils extends NEIServerUtils {
}
private static boolean consumeFluid(List<ItemStack> invStacks, Map<ItemStack, Long> remainingFluid,
FluidStack requiredFluid, long requiredAmount) {
long need = requiredAmount;
FluidStack requiredFluid) {
long need = requiredFluid.amount;
final List<ItemStack> matched = new ArrayList<>();
for (ItemStack is : invStacks) {
@@ -365,7 +364,7 @@ public class NEIClientUtils extends NEIServerUtils {
return false;
}
long remainingNeed = requiredAmount;
long remainingNeed = requiredFluid.amount;
for (ItemStack is : matched) {
final long available = remainingFluid.get(is);
final long consumed = Math.min(available, remainingNeed);
@@ -539,40 +538,6 @@ public class NEIClientUtils extends NEIServerUtils {
return null;
}
public static int countMissingIngredients(List<PositionedStack> ingredients, Map<Item, List<ItemStack>> index,
int limit) {
Map<ItemStack, Integer> usedItems = new HashMap<>();
int missing = 0;
for (PositionedStack pStack : ingredients) {
ItemStack used = null;
for (ItemStack permutation : pStack.items) {
final List<ItemStack> candidates = index.get(permutation.getItem());
if (candidates == null) continue;
for (ItemStack is : candidates) {
if (usedItems.getOrDefault(is, is.stackSize) >= pStack.item.stackSize
&& NEIServerUtils.areStacksSameTypeCrafting(permutation, is)) {
used = is;
break;
}
}
if (used != null) break;
}
if (used != null) {
usedItems.put(used, usedItems.getOrDefault(used, used.stackSize) - pStack.item.stackSize);
} else if (++missing >= limit) {
return missing;
}
}
return missing;
}
public static boolean altKey() {
return Keyboard.isKeyDown(Keyboard.KEY_LMENU) || Keyboard.isKeyDown(Keyboard.KEY_RMENU);
}
@@ -303,9 +303,8 @@ public class PositionedStack implements Cloneable {
if (fluidStack != null && this.capacity > 0) {
tooltip.add(
EnumChatFormatting.GRAY + NEIClientUtils.translate(
"recipe.fluid.tank.amount",
NEIClientUtils.formatFluid(StackInfo.getAmountLong(this.item))));
EnumChatFormatting.GRAY + NEIClientUtils
.translate("recipe.fluid.tank.amount", NEIClientUtils.formatFluid(fluidStack.amount)));
}
if (customTooltip != null) {
@@ -21,7 +21,6 @@ import codechicken.nei.BookmarkContainerInfo;
import codechicken.nei.FavoriteRecipes;
import codechicken.nei.ItemPanels;
import codechicken.nei.ItemQuantityField;
import codechicken.nei.ItemStackAmount;
import codechicken.nei.KeyManager;
import codechicken.nei.LayoutManager;
import codechicken.nei.NEIClientConfig;
@@ -718,7 +717,7 @@ public abstract class ShortcutInputHandler {
private static void autocraftingIgnoreInventory(RecipeChainMath math) {
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
final List<ItemStack> playerInventory = ItemStackAmount.of(guiContainer).values();
final List<ItemStack> playerInventory = AutoCraftingManager.getInventoryItems(guiContainer).values();
final RecipeId rootRecipeId = math.createMasterRoot();
for (int i = 0; i < math.recipeIngredients.size(); i++) {
@@ -729,7 +728,7 @@ public abstract class ShortcutInputHandler {
for (ItemStack stack : playerInventory) {
if (NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
amount += StackInfo.getAmountLong(stack);
amount += StackInfo.getAmount(stack);
}
}
@@ -194,8 +194,7 @@ public class BookmarkGridGenerator {
|| group.crafting.calculatedItems.get(shadowIndex).calculatedType == CalculatedType.INGREDIENT;
final BookmarkItem shadowBookmarkItem = BookmarkItem.builder(bookmarkItem.groupId, bookmarkItem.itemStack)
.multiplier(1).factor(StackInfo.getAmountLong(bookmarkItem.itemStack))
.recipeId(bookmarkItem.recipeId)
.multiplier(1).factor(StackInfo.getAmount(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.getLong("Count"), 1) : 1;
this.factor = StackInfo.isFluidDisplayItem(stack) ? Math.max(nbTag.getInteger("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.getAmountLong(this.stack) / this.factor;
multiplier = StackInfo.getAmount(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.getAmountLong(perm) * res.getChance();
amount += 1L * StackInfo.getAmount(perm) * res.getChance();
break;
}
}
@@ -271,15 +271,15 @@ public class BookmarkItem {
}
if (jsonObject.has("multiplier")) {
builder.multiplier(jsonObject.get("multiplier").getAsLong());
builder.multiplier(jsonObject.get("multiplier").getAsInt());
}
if (jsonObject.has("factor")) {
builder.factor(jsonObject.get("factor").getAsLong());
builder.factor(jsonObject.get("factor").getAsInt());
}
if (jsonObject.has("chance")) {
builder.chance(jsonObject.get("chance").getAsLong());
builder.chance(jsonObject.get("chance").getAsInt());
}
if (jsonObject.get("recipeId") instanceof JsonObject recipeJson) {
@@ -320,9 +320,8 @@ public class BookmarkItem {
final ItemStack newPerm = findPermutation(stack);
if (oldPerm != null && newPerm != null) {
final long oldAmount = StackInfo.getAmountLong(oldPerm);
final long amount = oldAmount > 0
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
final long oldAmount = StackInfo.getAmount(oldPerm);
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
: 0;
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
: 1;
@@ -370,9 +369,8 @@ public class BookmarkItem {
final ItemStack newPerm = findPermutation(perm);
if (oldPerm != null && newPerm != null) {
final long oldAmount = StackInfo.getAmountLong(oldPerm);
final long amount = oldAmount > 0
? this.factor * this.chance * StackInfo.getAmountLong(newPerm) / oldAmount
final long oldAmount = StackInfo.getAmount(oldPerm);
final long amount = oldAmount > 0 ? this.factor * this.chance * StackInfo.getAmount(newPerm) / oldAmount
: 0;
final long factor = (amount % PositionedStack.CHANCE_FULL) == 0 ? amount / PositionedStack.CHANCE_FULL
: 1;
@@ -52,7 +52,14 @@ class CraftingTreeToolbar {
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslated(iconX, iconY, 0);
GL11.glScalef(0.5f, 0.5f, 1);
icon.bindTexture();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
icon.draw(0, 0);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
@@ -36,7 +36,6 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import codechicken.lib.gui.GuiDraw;
import codechicken.nei.ItemStackAmount;
import codechicken.nei.KeyManager;
import codechicken.nei.LRUCache;
import codechicken.nei.NEICPH;
@@ -61,6 +60,7 @@ import codechicken.nei.guihook.IGuiClientSide;
import codechicken.nei.guihook.IGuiHandleMouseWheel;
import codechicken.nei.guihook.IGuiHotkeyListener;
import codechicken.nei.recipe.AcceptsFollowingTooltipLineHandler;
import codechicken.nei.recipe.AutoCraftingManager;
import codechicken.nei.recipe.GuiCraftingRecipe;
import codechicken.nei.recipe.GuiOverlayButton;
import codechicken.nei.recipe.GuiRecipe;
@@ -284,8 +284,10 @@ public class GuiCraftingTree extends GuiContainer implements INEIGuiHandler, IGu
final GuiContainer firstGui = getFirstScreen();
if (firstGui != null) {
for (ItemStack stack : ItemStackAmount.of(firstGui).values()) {
this.math.initialItems.add(BookmarkItem.of(-1, stack));
for (ItemStack stack : AutoCraftingManager.getInventoryItems(firstGui).values()) {
if (stack != null) {
this.math.initialItems.add(BookmarkItem.of(-1, stack));
}
}
}
}
@@ -524,7 +524,7 @@ class StatsPanel extends ScrollContainer {
public ItemStack getStackMouseOver(int mouseX, int mouseY) {
final Widget widget = getWidgetUnderMouse(mouseX, mouseY);
return widget instanceof ItemStatsSlot slot ? slot.getStack() : null;
return widget instanceof ItemStatsSlot slot && slot.recipeId == null ? slot.getStack() : null;
}
public void setHighlight(SearchResult searchResult) {
@@ -220,9 +220,8 @@ public class DrawableResource extends Image {
final float scaleU = 1.0F / this.textureWidth;
final float scaleV = 1.0F / this.textureHeight;
// 1/64 shift keeps pixel centers off texel edges, where NEAREST picks a texel at random when downscaled
final double x = xOffset + this.paddingLeft + 1 / 64d;
final double y = yOffset + this.paddingTop + 1 / 64d;
final int x = xOffset + this.paddingLeft;
final int y = yOffset + this.paddingTop;
final float u0 = (this.x + u) * scaleU;
final float u1 = (this.x + u + width) * scaleU;
final float v0 = (this.y + v) * scaleV;
@@ -51,7 +51,6 @@ 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;
@@ -230,9 +229,7 @@ public class GuiContainerManager {
public static String itemCountDetails(ItemStack stack) {
final FluidStack fluid = StackInfo.getFluid(stack);
if (fluid != null) {
// 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));
return fluidAmountDetails(fluid.amount * Math.max(1, stack.stackSize));
} else {
return countDetails(
stack.stackSize,
@@ -246,35 +243,17 @@ public class GuiContainerManager {
@SuppressWarnings("unused")
@Nullable
public static String fluidAmountDetails(FluidStack fluid) {
return fluidAmountDetails(GTFluidStackStringifyHandler.getFluidAmount(fluid));
return fluidAmountDetails(fluid.amount);
}
@Nullable
public static String fluidAmountDetails(int amount) {
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(
return countDetails(
amount,
144,
translate("inventory.tooltip.count.fluid", "%s = %s * %s + %s"),
translate("inventory.tooltip.count.fluid", "%s = %s * %s"),
NEIClientUtils.formatFluid(amount),
units,
NEIClientUtils.formatFluid(144));
NEIClientUtils::formatFluid);
}
/**
@@ -661,7 +640,7 @@ public class GuiContainerManager {
tooltip = handler.handleTooltip(window, mousex, mousey, tooltip);
}
ItemStack stack = tooltip.isEmpty() ? getStackMouseOver(window) : null;
ItemStack stack = getStackMouseOver(window);
boolean showTooltip = shouldShowTooltip(window);
if (tooltip.isEmpty() && showTooltip) { // mouseover tip, not holding an item
font = getFontRenderer(stack);
@@ -958,11 +937,9 @@ public class GuiContainerManager {
}
public void keyTyped(char c, int k) {
KeyManager.handleKeyEvent(k, () -> {
if (firstKeyTyped(c, k)) return;
if (firstKeyTyped(c, k)) return;
callKeyTyped(window, c, k);
});
callKeyTyped(window, c, k);
}
private static void callKeyTyped(GuiContainer window, char c, int k) {
@@ -17,7 +17,6 @@ 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;
@@ -47,8 +46,7 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
}
public static ItemStack createStack(FluidStack fluidStack) {
return fluidStack == null ? null
: createStack(fluidStack.getFluid(), GTFluidStackStringifyHandler.getFluidAmount(fluidStack));
return fluidStack == null ? null : createStack(fluidStack.getFluid(), fluidStack.amount);
}
public static ItemStack createStack(Fluid fluid, long amount) {
@@ -265,8 +265,8 @@ public final class MobOverlayScan {
}
/**
* {@link #moveTo} reads a column's chunk, biome and highest non-air block in the box, and {@link #scan} reads the
* column's blocks.
* {@link #moveTo} reads the chunk, the height map and the biome of a column, and {@link #scan} reads the column's
* blocks.
*/
private final class Column {
@@ -285,14 +285,15 @@ public final class MobOverlayScan {
canBiomeSpawn = !biome.getSpawnableList(EnumCreatureType.monster).isEmpty()
&& biome.getSpawningChance() > 0;
chunk = scannedWorld.getChunkFromBlockCoords(x, z);
// `getHeightValue()` is the height above the highest block with a light opacity above 0. A block with a
// light opacity of 0 can be higher: Tinkers' Construct slime grass, a hopper or a snow layer. A mob can
// spawn on top of slime grass, a hopper or a full snow block. Search the blocks for the highest non-air
// block
final int SECTION_HEIGHT = 16;
int y = Math.min(minY + height - 1, chunk.getTopFilledSegment() + SECTION_HEIGHT - 1);
while (y >= minY && chunk.getBlock(x & 15, y, z & 15).isAir(chunk.worldObj, x, y, z)) y--;
topY = y + 1;
// on the client, `Chunk.generateHeightMap()` never tests the top layer of the highest non-empty section.
// `getHeightValue()` can then be below a block on that layer, so test that layer here
final int topLayerY = chunk.getTopFilledSegment() + 15;
final boolean isTopLayerFilled = !chunk.isEmpty() && chunk.func_150808_b(x & 15, topLayerY, z & 15) != 0;
final int heightValue = isTopLayerFilled ? topLayerY + 1 : scannedWorld.getHeightValue(x, z);
// `getHeightValue()` is the height above the highest block with a light opacity above 0. A snow layer and a
// hopper have a light opacity of 0, and a mob can spawn on top of a full snow block or a hopper, so scan
// one block above the height value
topY = Math.min(scannedWorld.getHeight() - 1, heightValue + 1);
}
/** @return whether a spawn mode or the top of a flat block changed */
@@ -32,7 +32,7 @@ public class AutoCraftingManager {
public void execute() {
final GuiContainer guiContainer = NEIClientUtils.getGuiContainer();
final ItemStack[] layout = snapshotLayout(guiContainer);
final List<BookmarkItem> initialItems = prepareInitialItems(math, ItemStackAmount.of(guiContainer));
final List<BookmarkItem> initialItems = prepareInitialItems(math, getInventoryItems(guiContainer));
boolean processed = false;
boolean changed = false;
@@ -43,7 +43,7 @@ public class AutoCraftingManager {
changed = false;
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
iterator.updateInventory(ItemStackAmount.of(guiContainer));
iterator.updateInventory(getInventoryItems(guiContainer));
while (iterator.hasNext() && !interrupted(guiContainer)) {
final Map<RecipeId, Long> recipes = iterator.next();
@@ -69,7 +69,7 @@ public class AutoCraftingManager {
if (craft) {
changed = true;
processed = true;
iterator.updateInventory(ItemStackAmount.of(guiContainer));
iterator.updateInventory(getInventoryItems(guiContainer));
}
}
@@ -138,6 +138,18 @@ public class AutoCraftingManager {
return AutoCraftingManager.math != null && !task.interrupted();
}
public static ItemStackAmount getInventoryItems(GuiContainer guiContainer) {
final ItemStackAmount inventory = new ItemStackAmount();
for (Slot slot : guiContainer.inventorySlots.inventorySlots) {
if (slot.getHasStack() && !(slot instanceof SlotCrafting) && slot.canTakeStack(guiContainer.mc.thePlayer)) {
inventory.add(slot.getStack());
}
}
return inventory;
}
private static ItemStack[] snapshotLayout(GuiContainer guiContainer) {
final List<Slot> slots = guiContainer.inventorySlots.inventorySlots;
final ItemStack[] layout = new ItemStack[slots.size()];
@@ -59,7 +59,6 @@ import codechicken.nei.scroll.ScrollBar.OverflowType;
import codechicken.nei.scroll.ScrollBar.ScrollPlace;
import codechicken.nei.scroll.ScrollContainer;
import codechicken.nei.search.SearchExpressionUtils;
import codechicken.nei.theme.UIWidgetTexture;
import codechicken.nei.util.EmptyContainer;
import codechicken.nei.util.SlotInaccessible;
@@ -112,7 +111,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
private Rectangle pageArea = new Rectangle();
private int lastPage = -1;
private int catalystsVersion = -1;
private final GuiRecipeTabs recipeTabs;
private final GuiRecipeCatalyst recipeCatalyst;
private SearchRecipeHandler<H> handler;
@@ -534,7 +532,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (!this.handlerInfo.isAllowOverflowX() && this.handlerInfo.getWidth() > this.xSize - 6) {
this.container.setPaddingInline(0, 2);
this.container.setHorizontalScroll(UIWidgetTexture.horizontalScrollBar().setTrackPadding(1, 0, 1, 0));
this.container.setHorizontalScroll(ScrollBar.defaultHorizontalBar().setTrackPadding(1, 0, 1, 0));
} else {
this.container.setPaddingInline(0, 0);
this.container.setHorizontalScroll(null);
@@ -546,16 +544,12 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
this.container.setVerticalScroll(VERTICAL_SCROLLBAR);
} else {
this.container.setVerticalScroll(
UIWidgetTexture.verticalScrollBar().setOverflowType(OverflowType.OVERLAY)
ScrollBar.defaultVerticalBar().setOverflowType(OverflowType.OVERLAY)
.setTrackPadding(-8, 0, 0, 0));
}
}
if (this.catalystsVersion != RecipeCatalysts.getVersion()) {
this.catalystsVersion = RecipeCatalysts.getVersion();
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
}
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
this.container.update();
}
@@ -586,8 +580,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
this.recipetype = (this.currenthandlers.size() + idx) % this.currenthandlers.size();
this.handler = new SearchRecipeHandler<>(this.currenthandlers.get(this.recipetype));
this.handlerInfo = GuiRecipeTab.getHandlerInfo(this.handler.original);
this.catalystsVersion = RecipeCatalysts.getVersion();
this.recipeCatalyst.setCatalysts(RecipeCatalysts.getRecipeCatalysts(this.handler.original));
updateContainerSize();
this.handlerPages = new RecipePageManager(this.handler, this.handlerInfo, this.container);
this.prevpage.enabled = this.nextpage.enabled = this.handlerPages.getNumPages() > 1;
@@ -4,14 +4,10 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraftforge.client.event.GuiScreenEvent;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.GuiNEIButton;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.theme.ButtonSkin;
import codechicken.nei.theme.UIWidgetTexture;
import cpw.mods.fml.common.eventhandler.Cancelable;
public abstract class GuiRecipeButton extends GuiNEIButton {
@@ -62,26 +58,6 @@ public abstract class GuiRecipeButton extends GuiNEIButton {
this.handlerRef = point;
}
protected DrawableResource getIcon() {
return null;
}
@Override
protected DrawableResource getBackground(int mouseX, int mouseY, boolean mouseOver) {
return UIWidgetTexture.BUTTON.background(this.enabled, false, mouseOver);
}
@Override
protected void drawContent(Minecraft minecraft, int mouseX, int mouseY, boolean mouseOver) {
final DrawableResource icon = getIcon();
if (icon != null) {
ButtonSkin.drawIcon(this.xPosition, this.yPosition, this.width, this.height, icon, this.enabled);
} else {
super.drawContent(minecraft, mouseX, mouseY, mouseOver);
}
}
public abstract List<String> handleTooltip(List<String> currenttip);
public abstract Map<String, String> handleHotkeys(int mousex, int mousey, Map<String, String> hotkeys);
@@ -1,7 +1,6 @@
package codechicken.nei.recipe;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.lwjgl.opengl.GL11;
@@ -18,7 +17,6 @@ import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.scroll.ScrollBar;
import codechicken.nei.scroll.ScrollContainer;
import codechicken.nei.theme.UIWidgetTexture;
public class GuiRecipeCatalyst extends ScrollContainer {
@@ -69,26 +67,25 @@ public class GuiRecipeCatalyst extends ScrollContainer {
private static final DrawableResource FG_TEXTURE = new DrawableBuilder("nei:textures/slot.png", 0, 0, 18, 18)
.setTextureSize(18, 18).setSlices(1, 1, 1, 1).build();
private static final ScrollBar VERTICAL_SCROLLBAR = UIWidgetTexture.verticalScrollBar()
private static final ScrollBar VERTICAL_SCROLLBAR = ScrollBar.defaultVerticalBar()
.setOverflowType(ScrollBar.OverflowType.AUTO).setTrackPadding(0, BORDER_PADDING, -13, BORDER_PADDING)
.setScrollPlace(ScrollBar.ScrollPlace.START);
private List<PositionedStack> items = Collections.emptyList();
private PositionedStack[] items = new PositionedStack[0];
private boolean showWidget = false;
private int availableHeight = 0;
private int style = -1;
public GuiRecipeCatalyst() {
setPaddingBlock(BORDER_PADDING + 1, BORDER_PADDING + 1);
}
public void setCatalysts(List<PositionedStack> items) {
this.items = items;
this.items = items.toArray(new PositionedStack[0]);
createWidgets();
}
public void setAvailableHeight(int height) {
if (this.availableHeight != height || this.style != NEIClientConfig.getJEIStyleRecipeCatalysts()) {
if (this.availableHeight != height) {
this.availableHeight = height;
createWidgets();
}
@@ -105,14 +102,14 @@ public class GuiRecipeCatalyst extends ScrollContainer {
public int getColumnCount() {
if (NEIClientConfig.getJEIStyleRecipeCatalysts() == 1) {
final int maxItemsPerColumn = Math.max(0, this.availableHeight - 2 - BORDER_PADDING * 2) / SLOT_SIZE;
return maxItemsPerColumn > 0 ? NEIServerUtils.divideCeil(this.items.size(), maxItemsPerColumn) : 0;
return maxItemsPerColumn > 0 ? NEIServerUtils.divideCeil(this.items.length, maxItemsPerColumn) : 0;
}
return 1;
}
public int getRowCount() {
final int columnCount = getColumnCount();
return columnCount > 0 ? NEIServerUtils.divideCeil(this.items.size(), columnCount) : 0;
return columnCount > 0 ? NEIServerUtils.divideCeil(this.items.length, columnCount) : 0;
}
protected void createWidgets() {
@@ -122,11 +119,10 @@ public class GuiRecipeCatalyst extends ScrollContainer {
setVerticalScroll(null);
setPaddingInline(BORDER_PADDING + 1, BORDER_PADDING - 3);
this.style = NEIClientConfig.getJEIStyleRecipeCatalysts();
this.h = rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd;
this.w = columns * SLOT_SIZE + this.paddingInlineStart + this.paddingInlineEnd;
if (this.style == 2
if (NEIClientConfig.getJEIStyleRecipeCatalysts() == 2
&& rows * SLOT_SIZE + this.paddingBlockStart + this.paddingBlockEnd > this.availableHeight) {
this.h = Math.min(this.h, this.availableHeight);
this.w += VERTICAL_SCROLLBAR.getTrackWidth();
@@ -138,7 +134,6 @@ public class GuiRecipeCatalyst extends ScrollContainer {
this.showWidget = rows * columns > 0;
if (rows == 0 || columns == 0) {
clear();
return;
}
@@ -487,11 +487,11 @@ public class Recipe {
stack = getMainResult(getResults(), RecipeIngredient::getItemStack).getItemStack();
}
long stackSize = 0;
int stackSize = 0;
for (RecipeIngredient result : this.results) {
if (result.contains(stack)) {
stackSize += StackInfo.getAmountLong(result.getItemStack());
stackSize += result.getAmount();
}
}
@@ -36,11 +36,6 @@ public class RecipeCatalysts {
public static final Map<String, List<ItemStack>> catalystsRemoverFromIMC = new HashMap<>();
private static final Map<String, List<PositionedStack>> recipeCatalystMap = new HashMap<>();
private static final List<String> forceClassNameList = new ArrayList<>();
private static int version = 0;
public static int getVersion() {
return version;
}
public static void addRecipeCatalyst(String handlerID, CatalystInfo catalystInfo) {
if (handlerID == null || handlerID.isEmpty() || catalystInfo.getStack() == null) return;
@@ -74,7 +69,6 @@ public class RecipeCatalysts {
if (handlerID == null || handlerID.isEmpty()) return;
catalystsAdderFromAPI.put(handlerID, catalystInfoList);
recipeCatalystMap.put(handlerID, convertToPositionedStackList(catalystInfoList));
version++;
}
public static List<PositionedStack> getRecipeCatalysts(IRecipeHandler handler) {
@@ -182,7 +176,6 @@ public class RecipeCatalysts {
recipeCatalystMap.put(entry.getKey(), convertToPositionedStackList(entry.getValue()));
}
version++;
}
private static void resolveAdderQueue(Map<String, CatalystInfoList> recipeCatalystMap) {
@@ -271,7 +271,7 @@ public class RecipeItemsTooltipLineHandler extends CompositeTooltipLineHandler {
}
if (screen instanceof GuiContainer container) {
return ItemStackAmount.of(container);
return AutoCraftingManager.getInventoryItems(container);
}
return new ItemStackAmount();
@@ -121,13 +121,9 @@ 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.getLong("Count") : 0;
return nbTag != null ? nbTag.getInteger("Count") : 0;
}
public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolean useNBT) {
@@ -27,6 +27,7 @@ import codechicken.nei.NEIClientUtils;
import codechicken.nei.bookmark.BookmarkItem;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.guihook.GuiContainerManager;
import codechicken.nei.recipe.AutoCraftingManager;
import codechicken.nei.recipe.GuiRecipe;
import codechicken.nei.recipe.GuiRecipeTab;
import codechicken.nei.recipe.HandlerInfo;
@@ -136,7 +137,7 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
final GuiContainer currentGui = NEIClientUtils.getGuiContainer();
if (this.lastShiftKey && currentGui != null && !(currentGui instanceof GuiRecipe<?>)) {
inventory.putAll(ItemStackAmount.of(currentGui));
inventory.putAll(AutoCraftingManager.getInventoryItems(currentGui));
}
if (!this.outputRecipes.isEmpty()) {
@@ -155,7 +156,7 @@ public class RecipeChainTooltipLineHandler extends CompositeTooltipLineHandler {
for (ItemStack stack : items) {
if (stack != null
&& NEIClientUtils.areStacksSameTypeCraftingWithNBT(stack, item.itemStack)) {
amount += StackInfo.getAmountLong(stack);
amount += StackInfo.getAmount(stack);
}
}
@@ -22,7 +22,6 @@ 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;
@@ -43,12 +42,6 @@ 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",
@@ -59,18 +52,6 @@ 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) {
@@ -80,7 +61,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
if (fluidStack != null) {
final NBTTagCompound nbTag = new NBTTagCompound();
nbTag.setString(FluidDisplayStackStringifyHandler.NBT_FLUID_NAME, fluidStack.getFluid().getName());
nbTag.setLong("Count", saveStackSize ? getFluidAmount(fluidStack) : 144);
nbTag.setInteger("Count", saveStackSize ? fluidStack.amount : 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.getAmountLong(stackA) == StackInfo.getAmountLong(stackB);
&& StackInfo.getAmount(stackA) == StackInfo.getAmount(stackB);
}
protected List<ItemStack> getFilteredPermutations(int member, Point slotKey) {
@@ -6,8 +6,8 @@ import org.lwjgl.opengl.GL11;
import codechicken.lib.vec.Rectangle4i;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.drawable.DrawableBuilder;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.theme.UIWidgetTexture;
public class ScrollBar {
@@ -59,14 +59,21 @@ public class ScrollBar {
return new ScrollBar();
}
@Deprecated
public static ScrollBar defaultVerticalBar() {
return UIWidgetTexture.verticalScrollBar();
return new ScrollBar().setTrackWidth(8).setTrackTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 29, 95, 8, 11).setSlices(0, 0, 3, 4).build())
.setThumbTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 22, 96, 6, 9).setSlices(0, 0, 3, 2).build())
.setThumbPadding(1, 1, 1, 1);
}
@Deprecated
public static ScrollBar defaultHorizontalBar() {
return UIWidgetTexture.horizontalScrollBar();
return new ScrollBar().setTrackWidth(8).setOverflowType(OverflowType.SCROLL)
.setTrackTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 0, 97, 11, 8).setSlices(3, 4, 0, 0).build())
.setThumbTexture(
new DrawableBuilder("nei:textures/nei_sprites.png", 12, 98, 9, 6).setSlices(3, 2, 0, 0).build())
.setThumbPadding(1, 1, 1, 1);
}
/**
@@ -1,44 +0,0 @@
package codechicken.nei.theme;
import org.lwjgl.opengl.GL11;
import codechicken.nei.drawable.DrawableResource;
public final class ButtonSkin {
private final DrawableResource normal;
private final DrawableResource hover;
private final DrawableResource active;
private final DrawableResource disabled;
public ButtonSkin(DrawableResource normal, DrawableResource hover, DrawableResource active,
DrawableResource disabled) {
this.normal = normal;
this.hover = hover;
this.active = active;
this.disabled = disabled;
}
public DrawableResource background(boolean enabled, boolean active, boolean hovered) {
if (!enabled) return this.disabled;
if (active) return this.active;
return hovered ? this.hover : this.normal;
}
public void draw(int x, int y, int w, int h, DrawableResource icon, boolean enabled, boolean active,
boolean hovered) {
GL11.glColor4f(1, 1, 1, 1);
background(enabled, active, hovered).draw(x, y, w, h);
drawIcon(x, y, w, h, icon, enabled);
}
public static void drawIcon(int x, int y, int w, int h, DrawableResource icon, boolean enabled) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glColor4f(1, 1, 1, enabled ? 1 : 0.5f);
icon.draw(x + (w - icon.getWidth()) / 2, y + (h - icon.getHeight()) / 2);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1, 1, 1, 1);
}
}
@@ -1,58 +0,0 @@
package codechicken.nei.theme;
import net.minecraft.util.ResourceLocation;
import codechicken.nei.drawable.DrawableResource;
public final class UISprite {
public static final int[] DEFAULT_SPACE = new int[] { 0, 0, 0, 0 };
private UISprite() {}
public static DrawableResource of(String name, int w, int h, int[] margin, int[] slice) {
return frames(name, w, h, 1, margin, slice)[0];
}
public static DrawableResource of(String name, int w, int h) {
return of(name, w, h, DEFAULT_SPACE, DEFAULT_SPACE);
}
public static DrawableResource[] frames(String name, int w, int h, int count) {
return frames(name, w, h, count, DEFAULT_SPACE, DEFAULT_SPACE);
}
// frames are stacked top to bottom and each includes the margin; {left, top, right, bottom}
public static DrawableResource[] frames(String name, int w, int h, int count, int[] margin, int[] slice) {
final ResourceLocation texture = new ResourceLocation("nei", "textures/gui/" + name + ".png");
final int frameWidth = w + margin[0] + margin[2];
final int frameHeight = h + margin[1] + margin[3];
final DrawableResource[] frames = new DrawableResource[count];
for (int i = 0; i < count; i++) {
frames[i] = new DrawableResource(
texture,
0,
i * frameHeight,
frameWidth,
frameHeight,
-margin[1],
-margin[3],
-margin[0],
-margin[2],
frameWidth,
frameHeight * count,
slice[0] + margin[0],
slice[2] + margin[2],
slice[1] + margin[1],
slice[3] + margin[3]);
}
return frames;
}
}
@@ -1,45 +0,0 @@
package codechicken.nei.theme;
import codechicken.nei.drawable.DrawableResource;
import codechicken.nei.scroll.ScrollBar;
import codechicken.nei.scroll.ScrollBar.ScrollType;
public final class UIWidgetTexture {
private static final DrawableResource[] BTN = UISprite
.frames("widgets/button", 12, 12, 4, UISprite.DEFAULT_SPACE, new int[] { 2, 2, 2, 3 });
public static final DrawableResource BTN_NORMAL = BTN[0];
public static final DrawableResource BTN_HOVER = BTN[1];
public static final DrawableResource BTN_ACTIVE = BTN[2];
public static final DrawableResource BTN_DISABLED = BTN[3];
public static final ButtonSkin BUTTON = new ButtonSkin(BTN_NORMAL, BTN_HOVER, BTN_ACTIVE, BTN_DISABLED);
private static final int[] THUMB_INSET = new int[] { 1, 1, 1, 1 };
// frame 0 is the track, frame 1 the thumb drawn inside a transparent THUMB_INSET border of the same frame size
public static final DrawableResource SCROLL_V_TRACK = UISprite
.frames("widgets/scroll_v", 8, 11, 2, UISprite.DEFAULT_SPACE, new int[] { 1, 1, 1, 1 })[0];
public static final DrawableResource SCROLL_V_THUMB = UISprite
.frames("widgets/scroll_v", 6, 9, 2, THUMB_INSET, new int[] { 1, 1, 1, 2 })[1];
public static final DrawableResource SCROLL_H_TRACK = UISprite
.frames("widgets/scroll_h", 11, 8, 2, UISprite.DEFAULT_SPACE, new int[] { 1, 1, 1, 1 })[0];
public static final DrawableResource SCROLL_H_THUMB = UISprite
.frames("widgets/scroll_h", 9, 6, 2, THUMB_INSET, new int[] { 1, 1, 2, 1 })[1];
public static final int SCROLL_TRACK_WIDTH = 8;
private UIWidgetTexture() {}
public static ScrollBar verticalScrollBar() {
return new ScrollBar().setTrackWidth(SCROLL_TRACK_WIDTH).setTrackTexture(SCROLL_V_TRACK)
.setThumbTexture(SCROLL_V_THUMB).setThumbPadding(1, 1, 1, 1);
}
public static ScrollBar horizontalScrollBar() {
return new ScrollBar().setScrollType(ScrollType.HORIZONTAL).setTrackWidth(SCROLL_TRACK_WIDTH)
.setTrackTexture(SCROLL_H_TRACK).setThumbTexture(SCROLL_H_THUMB).setThumbPadding(1, 1, 1, 1);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B