Compare commits

...
5 Commits
5 changed files with 41 additions and 19 deletions

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
//version: 1697697256
//version: 1698936026
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -646,7 +646,7 @@ repositories {
def mixinProviderGroup = "io.github.legacymoddingmc"
def mixinProviderModule = "unimixins"
def mixinProviderVersion = "0.1.7.1"
def mixinProviderVersion = "0.1.13"
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
ext.mixinProviderSpec = mixinProviderSpec
@@ -476,7 +476,6 @@ public class NEIClientConfig {
RecipeInfo.load();
LayoutManager.load();
NEIController.load();
RecipeCatalysts.loadCatalystInfo();
BookmarkContainerInfo.load();
mainNEIConfigLoaded = true;
@@ -502,6 +501,8 @@ public class NEIClientConfig {
}
}
RecipeCatalysts.loadCatalystInfo();
// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the other
// way around, but apparently if your modpack includes 800 mods the event poster might not return in
// time and cause issues when loading a world for a second time as configLoaded is still false. This may
@@ -10,10 +10,8 @@ import net.minecraft.item.ItemStack;
import com.google.common.collect.ForwardingList;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIServerUtils;
// Do not directly extend ArrayList, see Effective Java Item 16
public class CatalystInfoList extends ForwardingList<CatalystInfo> {
private final String handlerID;
@@ -34,16 +32,21 @@ public class CatalystInfoList extends ForwardingList<CatalystInfo> {
}
@Override
public boolean add(@Nonnull CatalystInfo catalystInfo) {
if (contains(catalystInfo)) {
NEIClientConfig.logger.info(
String.format(
"catalyst %s is already registered to handler %s",
catalystInfo.getStack().getDisplayName(),
handlerID));
return false;
public boolean add(@Nonnull CatalystInfo element) {
return doAdd(element);
}
public boolean add(@Nonnull CatalystInfo catalystInfo, boolean overwrite) {
if (overwrite || !contains(catalystInfo)) {
return add(catalystInfo);
}
super.add(catalystInfo);
return false;
}
private boolean doAdd(@Nonnull CatalystInfo catalystInfo) {
catalystInfoList
.removeIf(c -> NEIServerUtils.areStacksSameTypeCraftingWithNBT(c.getStack(), catalystInfo.getStack()));
catalystInfoList.add(catalystInfo);
return true;
}
@@ -118,8 +118,8 @@ public class DefaultOverlayHandler implements IOverlayHandler {
ItemStack stack = slot.getStack();
if (!canStack(stack, pstack)) continue;
FastTransferManager.clickSlot(gui, slot.slotNumber);
int amount = Math.min(transferCap - transferred, stack.stackSize);
FastTransferManager.clickSlot(gui, slot.slotNumber);
for (int c = 0; c < amount; c++) {
FastTransferManager.clickSlot(gui, dest.slotNumber, 1);
transferred++;
@@ -132,6 +132,8 @@ public class RecipeCatalysts {
recipeCatalystMap.clear();
URL handlerUrl = RecipeCatalysts.class.getResource("/assets/nei/csv/catalysts.csv");
resolveAdderQueue();
URL url;
if (fromJar) {
url = handlerUrl;
@@ -208,13 +210,23 @@ public class RecipeCatalysts {
handlerID = handler;
}
addOrPut(recipeCatalystMap, handlerID, catalystInfo);
// Prefer info added by API if we're using default jar config.
// If not, user config overwrites it.
addOrPut(recipeCatalystMap, handlerID, catalystInfo, !fromJar);
}
} catch (Exception e) {
NEIClientConfig.logger.warn("Error parsing CSV");
e.printStackTrace();
}
if (fromJar) {
resolveRemoverQueue();
}
updatePosition(getHeight(), true);
}
private static void resolveAdderQueue() {
for (Map.Entry<String, CatalystInfoList> entry : catalystsAdderFromAPI.entrySet()) {
String handlerID = entry.getKey();
for (CatalystInfo catalyst : entry.getValue()) {
@@ -243,6 +255,9 @@ public class RecipeCatalysts {
}
});
}
}
private static void resolveRemoverQueue() {
for (Map.Entry<String, List<ItemStack>> entry : catalystsRemoverFromAPI.entrySet()) {
String handlerID = entry.getKey();
if (recipeCatalystMap.containsKey(handlerID)) {
@@ -258,8 +273,6 @@ public class RecipeCatalysts {
entry.getValue().forEach(catalysts::remove);
}
}
updatePosition(getHeight(), true);
}
/**
@@ -275,8 +288,13 @@ public class RecipeCatalysts {
}
public static void addOrPut(Map<String, CatalystInfoList> map, String handlerID, CatalystInfo catalyst) {
addOrPut(map, handlerID, catalyst, false);
}
public static void addOrPut(Map<String, CatalystInfoList> map, String handlerID, CatalystInfo catalyst,
boolean overwrite) {
if (map.containsKey(handlerID)) {
map.get(handlerID).add(catalyst);
map.get(handlerID).add(catalyst, overwrite);
} else {
map.put(handlerID, new CatalystInfoList(handlerID, catalyst));
}