Skip to content

Commit

Permalink
Merge remote-tracking branch 'slprime/fix_nei_loading' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/codechicken/nei/NEIClientConfig.java
  • Loading branch information
Dream-Master committed Dec 31, 2024
2 parents 7a1065e + 8581394 commit 4298d7d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
33 changes: 16 additions & 17 deletions src/main/java/codechicken/nei/NEIClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -723,21 +723,25 @@ public static OptionList getOptionList() {

public static void loadWorld(String worldPath) {
unloadWorld();
NEIClientConfig.worldPath = worldPath;

setInternalEnabled(true);
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");

final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
final boolean newWorld = !specificDir.exists();
if (!worldPath.equals(NEIClientConfig.worldPath)) {
NEIClientConfig.worldPath = worldPath;

if (newWorld) {
specificDir.mkdirs();
}
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");

final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
final boolean newWorld = !specificDir.exists();

if (newWorld) {
specificDir.mkdirs();
}

world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
bootNEI(ClientUtils.getWorld());
onWorldLoad(newWorld);
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
bootNEI(ClientUtils.getWorld());
onWorldLoad(newWorld);
ItemPanels.bookmarkPanel.load();
}
}

public static String getWorldPath() {
Expand Down Expand Up @@ -838,9 +842,8 @@ public void run() {
});

RecipeCatalysts.loadCatalystInfo();
ItemPanels.bookmarkPanel.load();
SubsetWidget.loadHidden();
CollapsibleItems.load();
SubsetWidget.loadHidden();
ItemSorter.loadConfig();

// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the
Expand All @@ -854,10 +857,6 @@ public void run() {
ItemList.loadItems.restart();
}
}.start();
} else {
ItemPanels.bookmarkPanel.load();
SubsetWidget.loadHidden();
ItemList.loadItems.restart();
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/main/java/codechicken/nei/recipe/StackInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;

Expand All @@ -21,6 +22,7 @@

public class StackInfo {

private static final FluidStack NULL_FLUID = new FluidStack(FluidRegistry.WATER, 0);
public static final ArrayList<IStackStringifyHandler> stackStringifyHandlers = new ArrayList<>();
private static final HashMap<String, HashMap<String, String[]>> guidfilters = new HashMap<>();
private static final ItemStackMap<String> guidcache = new ItemStackMap<>();
Expand All @@ -30,7 +32,7 @@ public class StackInfo {

@Override
protected boolean removeEldestEntry(Map.Entry<ItemStack, FluidStack> eldest) {
return size() > 20;
return size() > 200;
}
};

Expand Down Expand Up @@ -92,7 +94,7 @@ public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolea
return true;
}

public static FluidStack getFluid(ItemStack stack) {
public static synchronized FluidStack getFluid(ItemStack stack) {
FluidStack fluid = fluidcache.get(stack);

if (fluid == null && !fluidcache.containsKey(stack)) {
Expand All @@ -101,10 +103,10 @@ public static FluidStack getFluid(ItemStack stack) {
fluid = stackStringifyHandlers.get(i).getFluid(stack);
}

fluidcache.put(stack, fluid);
fluidcache.put(stack, fluid == null ? NULL_FLUID : fluid);
}

return fluid;
return fluid == NULL_FLUID ? null : fluid;
}

public static boolean isFluidContainer(ItemStack stack) {
Expand Down

0 comments on commit 4298d7d

Please sign in to comment.