Compare commits

...
Author SHA1 Message Date
slprime 4c74a01930 Fix crash when recipe search results change mid-rebuild (#1012) 2026-08-25 09:09:53 +03:00
slprime 6ced1e0604 Fix Fluid Untranslator (#1009) 2026-08-20 22:25:35 +03:00
slprime f8d00a5445 Add Accepts Label (#1007) 2026-08-14 22:41:15 +03:00
Taran Robertsandslprime 75d53b12ca New worlds ignoring global cheatmode (#1003)
Co-authored-by: slprime <[email protected]>
2026-08-14 16:20:31 +03:00
slprime f93d5977ed Fix Autocrafting With GTTools (#1006) 2026-08-14 15:22:35 +03:00
slprimeandgithub-actions[bot] c4f9c54200 Fix Autocrafting Infinity Loop (#1004)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-08-14 13:27:42 +03:00
12 changed files with 151 additions and 60 deletions

No files matched your search

@@ -92,6 +92,11 @@ public class ItemsTooltipLineHandler implements ITooltipLineHandler {
this.labelColor = color;
}
public void setLabel(String label) {
this.label = label;
this.size.width = Math.max(this.columns * SLOT_SIZE, fontRenderer.getStringWidth(this.label) + 15);
}
@Override
public void draw(int x, int y) {
if (this.length == 0) return;
@@ -882,9 +882,14 @@ public class NEIClientConfig {
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
if (newWorld && Minecraft.getMinecraft().isSingleplayer()) {
world.config.getTag("inventory.cheatmode")
.setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
if (newWorld && Minecraft.getMinecraft().isSingleplayer() && getLockedMode() == -1) {
final int globalMode = global.config.getTag("inventory.cheatmode").getIntValue();
final int worldMode = Math
.min(globalMode, NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0);
if (worldMode != globalMode) {
world.config.getTag("inventory.cheatmode").setIntValue(worldMode);
}
}
bootNEI();
@@ -37,6 +37,10 @@ public class PositionedStack implements Cloneable {
protected int chance = CHANCE_FULL;
protected boolean permutated = false;
protected String acceptsLabel;
protected List<String> tooltip;
protected List<Badge> badges;
public PositionedStack(Object object, int x, int y, boolean genPerms) {
items = NEIServerUtils.extractRecipeItems(object);
relx = x;
@@ -90,12 +94,28 @@ public class PositionedStack implements Cloneable {
for (ItemStack item : items) if (item.stackSize > i) item.stackSize = i;
}
public void setAcceptsLabel(String acceptsLabel) {
this.acceptsLabel = acceptsLabel;
}
public String getAcceptsLabel() {
return this.acceptsLabel;
}
public void setBadges(List<Badge> badges) {
this.badges = badges;
}
public List<Badge> getBadges() {
return null;
return this.badges;
}
public void setTooltip(List<String> tooltip) {
this.tooltip = tooltip;
}
public List<String> getTooltip() {
return null;
return this.tooltip;
}
public int getChance() {
@@ -111,6 +131,8 @@ public class PositionedStack implements Cloneable {
PositionedStack pStack = (PositionedStack) super.clone();
pStack.items = Arrays.stream(this.items).map(ItemStack::copy).toArray(ItemStack[]::new);
pStack.item = this.item == null ? null : this.item.copy();
pStack.tooltip = this.tooltip == null ? null : new ArrayList<>(this.tooltip);
pStack.badges = this.badges == null ? null : new ArrayList<>(this.badges);
return pStack;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
@@ -14,8 +14,9 @@ public class NEIInfo {
public static void load(World world) {
OptionCycled modeOption = (OptionCycled) NEIClientConfig.getOptionList().getOption("inventory.cheatmode");
final boolean worldConfig = NEIClientConfig.isWorldSpecific("inventory.cheatmode");
// kept alive so the WeakReference in Option.slotRef isn't GC'd before copyGlobals/cycle use it
GuiOptionList env = modeOption.parent.synthesizeEnvironment(false);
GuiOptionList env = modeOption.parent.synthesizeEnvironment(worldConfig);
if (!modeOption.optionValid(modeOption.value())) {
modeOption.copyGlobals();
modeOption.cycle();
@@ -15,7 +15,7 @@ public class AcceptsFollowingTooltipLineHandler extends ItemsTooltipLineHandler
public Object tooltipGUID;
public AcceptsFollowingTooltipLineHandler(Object tooltipGUID, List<ItemStack> items, ItemStack activeStack,
protected AcceptsFollowingTooltipLineHandler(Object tooltipGUID, List<ItemStack> items, ItemStack activeStack,
int maxRows) {
super(NEIClientUtils.translate("recipe.accepts"), items, false, maxRows);
this.tooltipGUID = tooltipGUID;
@@ -32,43 +32,46 @@ public class AutoCraftingManager {
StackInfo.pauseItemDamageSound(true);
do {
changed = false;
try {
do {
changed = false;
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
iterator.updateInventory(getInventoryItems(guiContainer));
RecipeChainIterator iterator = new RecipeChainIterator(math, initialItems);
iterator.updateInventory(getInventoryItems(guiContainer));
while (iterator.hasNext() && !interrupted(guiContainer)) {
final Map<RecipeId, Long> recipes = iterator.next();
boolean craft = false;
while (iterator.hasNext() && !interrupted(guiContainer)) {
final Map<RecipeId, Long> recipes = iterator.next();
boolean craft = false;
for (Map.Entry<RecipeId, Long> entry : recipes.entrySet()) {
final RecipeHandlerRef handler = RecipeHandlerRef.of(entry.getKey());
for (Map.Entry<RecipeId, Long> entry : recipes.entrySet()) {
final RecipeHandlerRef handler = RecipeHandlerRef.of(entry.getKey());
if (handler != null && handler.canCraft(guiContainer)) {
long multiplier = entry.getValue();
if (handler != null && handler.canCraft(guiContainer)) {
long multiplier = entry.getValue();
while (multiplier > 0 && !interrupted(guiContainer)
&& handler.craft(guiContainer, (int) Math.min(64, multiplier))) {
multiplier -= 64;
while (multiplier > 0 && !interrupted(guiContainer)
&& handler.craft(guiContainer, (int) Math.min(64, multiplier))) {
multiplier -= 64;
}
craft = craft || multiplier != entry.getValue();
}
craft = multiplier != entry.getValue();
if (interrupted(guiContainer)) break;
}
if (interrupted(guiContainer)) break;
if (craft) {
changed = true;
processed = true;
iterator.updateInventory(getInventoryItems(guiContainer));
}
}
if (craft) {
changed = true;
processed = true;
iterator.updateInventory(getInventoryItems(guiContainer));
}
}
} while (changed && !interrupted(guiContainer));
} while (changed && !interrupted(guiContainer));
StackInfo.pauseItemDamageSound(false);
} finally {
StackInfo.pauseItemDamageSound(false);
}
if (processed && !changed && !interrupted(guiContainer)) {
NEIClientUtils.playClickSound();
@@ -36,6 +36,7 @@ public class DefaultOverlayHandler implements IOverlayHandler {
public int numSlots;
public int recipeAmount;
public boolean isContainerItem = false;
public long damagePerContainerCraft;
}
public static class IngredientDistribution {
@@ -123,6 +124,11 @@ public class DefaultOverlayHandler implements IOverlayHandler {
if (craftingSlot.getHasStack() && craftingSlot.canTakeStack(firstGui.mc.thePlayer)) {
FastTransferManager.clickSlot(firstGui, craftingSlot.slotNumber, 0, 1);
if (craftingSlot.getHasStack()) {
break;
}
craft = true;
}
@@ -259,6 +265,11 @@ public class DefaultOverlayHandler implements IOverlayHandler {
final int maxStackSize = istack.stack.getMaxStackSize();
if (maxStackSize == 1 && istack.isContainerItem) {
if (istack.damagePerContainerCraft > 0) {
quantity = (int) Math.min(quantity, istack.damagePerContainerCraft);
}
// If non-stackable, fill up as much as possible of the other ingredients
continue;
}
@@ -372,7 +383,14 @@ public class DefaultOverlayHandler implements IOverlayHandler {
final NBTTagCompound tagCompound = pstack.getTagCompound();
if (tagCompound != null && tagCompound.hasKey("GT.ToolStats")) {
final NBTTagCompound toolStats = tagCompound.getCompoundTag("GT.ToolStats");
final long damagePerContainerCraft = getGTToolDamagePerContainerCraft(pstack);
final long maxDamage = toolStats.getLong("MaxDamage");
final long damage = toolStats.getLong("Damage");
istack.isContainerItem = true;
istack.damagePerContainerCraft = (maxDamage - damage + damagePerContainerCraft - 1)
/ damagePerContainerCraft;
} else {
final boolean isPausedItemDamageSound = StackInfo.isPausedItemDamageSound();
StackInfo.pauseItemDamageSound(true);
@@ -390,6 +408,19 @@ public class DefaultOverlayHandler implements IOverlayHandler {
}
}
private int getGTToolDamagePerContainerCraft(ItemStack aStack) {
try {
final Object toolStats = aStack.getItem().getClass().getMethod("getToolStats", ItemStack.class)
.invoke(aStack.getItem(), aStack);
return (int) toolStats.getClass().getMethod("getToolDamagePerContainerCraft").invoke(toolStats);
} catch (Throwable th) {
th.printStackTrace();
}
return 0;
}
protected List<DistributedIngred> getPermutationIngredients(List<PositionedStack> ingredients) {
ArrayList<DistributedIngred> ingredStacks = new ArrayList<>();
for (PositionedStack posstack : ingredients) /* work out what we need */ {
@@ -436,6 +436,10 @@ public class NEIRecipeWidget extends Widget {
|| this.acceptsFollowingTooltipLineHandler.tooltipGUID != hovered) {
this.acceptsFollowingTooltipLineHandler = AcceptsFollowingTooltipLineHandler
.of(hovered, this.permutations.get(hovered), hovered.item);
if (this.acceptsFollowingTooltipLineHandler != null && hovered.getAcceptsLabel() != null) {
this.acceptsFollowingTooltipLineHandler.setLabel(hovered.getAcceptsLabel());
}
}
} else if (this.acceptsFollowingTooltipLineHandler != null) {
this.acceptsFollowingTooltipLineHandler = null;
@@ -50,12 +50,13 @@ public class RecipePageManager {
final int heightAvailable = this.container.getVisibleHeight();
final int width = Math.max(166, this.handlerInfo.getWidth());
final int numRecipes = getNumRecipes();
final List<Integer> searchRecipes = this.handler.getFilteredRecipes();
final int numRecipes = searchRecipes.size();
List<Widget> widgets = new ArrayList<>();
int shiftY = 0;
for (int i = 0; i < numRecipes; i++) {
final int recipeIndex = this.handler.ref(i);
final int recipeIndex = searchRecipes.get(i);
final NEIRecipeWidget widget = RecipeHandlerRef.of(this.handler.original, recipeIndex).getRecipeWidget();
widget.w = width;
@@ -97,6 +97,22 @@ class SearchRecipeHandler<H extends IRecipeHandler> {
this.searchRecipes = searchRecipes;
}
public List<Integer> getFilteredRecipes() {
if (this.searchRecipes == null) {
return this.filteredRecipes;
}
final List<Integer> search = this.searchRecipes;
final List<Integer> resolved = new ArrayList<>(search.size());
for (int idx : search) {
resolved.add(this.filteredRecipes.get(idx));
}
return resolved;
}
public int ref(int index) {
if (searchRecipes != null) {
@@ -335,40 +335,43 @@ public class RecipeChainMath {
final boolean isPausedItemDamageSound = StackInfo.isPausedItemDamageSound();
StackInfo.pauseItemDamageSound(true);
resetCalculation();
try {
resetCalculation();
if (this.outputRecipes.containsKey(ROOT_RECIPE_ID)) {
for (BookmarkItem ingrItem : this.recipeIngredients) {
if (ROOT_RECIPE_ID.equals(ingrItem.recipeId)
&& ingrItem.itemStack.getItem().hasContainerItem(ingrItem.itemStack)) {
this.containerItemsBlacklist.add(ingrItem.itemStack);
if (this.outputRecipes.containsKey(ROOT_RECIPE_ID)) {
for (BookmarkItem ingrItem : this.recipeIngredients) {
if (ROOT_RECIPE_ID.equals(ingrItem.recipeId)
&& ingrItem.itemStack.getItem().hasContainerItem(ingrItem.itemStack)) {
this.containerItemsBlacklist.add(ingrItem.itemStack);
}
}
}
}
for (BookmarkItem prefItem : this.recipeResults) {
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)) {
final long prefMultiplier = this.outputRecipes.get(prefItem.recipeId);
for (BookmarkItem prefItem : this.recipeResults) {
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)) {
final long prefMultiplier = this.outputRecipes.get(prefItem.recipeId);
if (prefItem.itemStack.getItem().hasContainerItem(prefItem.itemStack)) {
this.containerItemsBlacklist.add(prefItem.itemStack);
if (prefItem.itemStack.getItem().hasContainerItem(prefItem.itemStack)) {
this.containerItemsBlacklist.add(prefItem.itemStack);
}
this.preferredItems.put(prefItem, prefItem);
calculateSuitableRecipe(prefItem, prefMultiplier, new ArrayList<>(), visitor);
this.preferredItems.remove(prefItem);
}
this.preferredItems.put(prefItem, prefItem);
calculateSuitableRecipe(prefItem, prefMultiplier, new ArrayList<>(), visitor);
this.preferredItems.remove(prefItem);
}
for (BookmarkItem prefItem : this.recipeResults) {
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)
&& this.requiredAmount.containsKey(prefItem)) {
final long prefAmount = prefItem.getAmount(this.outputRecipes.get(prefItem.recipeId));
this.requiredAmount.put(prefItem, this.requiredAmount.get(prefItem) - prefAmount);
}
}
} finally {
StackInfo.pauseItemDamageSound(isPausedItemDamageSound);
}
for (BookmarkItem prefItem : this.recipeResults) {
if (!prefItem.emptyFactor() && this.outputRecipes.containsKey(prefItem.recipeId)
&& this.requiredAmount.containsKey(prefItem)) {
final long prefAmount = prefItem.getAmount(this.outputRecipes.get(prefItem.recipeId));
this.requiredAmount.put(prefItem, this.requiredAmount.get(prefItem) - prefAmount);
}
}
StackInfo.pauseItemDamageSound(isPausedItemDamageSound);
return this;
}
@@ -145,7 +145,7 @@ public class ItemUntranslator {
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
items.put(
fluid.getUnlocalizedName().toLowerCase(),
stripFormatting(StatCollector.translateToLocal(fluid.getUnlocalizedName())));
stripFormatting(fluid.getLocalizedName(new FluidStack(fluid, 1))));
}
for (CreativeTabs tab : CreativeTabs.creativeTabArray) {