Skip to content

Commit 4298d7d

Browse files
committed
Merge remote-tracking branch 'slprime/fix_nei_loading' into dev
# Conflicts: # src/main/java/codechicken/nei/NEIClientConfig.java
2 parents 7a1065e + 8581394 commit 4298d7d

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/main/java/codechicken/nei/NEIClientConfig.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -723,21 +723,25 @@ public static OptionList getOptionList() {
723723

724724
public static void loadWorld(String worldPath) {
725725
unloadWorld();
726-
NEIClientConfig.worldPath = worldPath;
727-
728726
setInternalEnabled(true);
729-
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
730727

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

734-
if (newWorld) {
735-
specificDir.mkdirs();
736-
}
731+
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
732+
733+
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
734+
final boolean newWorld = !specificDir.exists();
735+
736+
if (newWorld) {
737+
specificDir.mkdirs();
738+
}
737739

738-
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
739-
bootNEI(ClientUtils.getWorld());
740-
onWorldLoad(newWorld);
740+
world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg")));
741+
bootNEI(ClientUtils.getWorld());
742+
onWorldLoad(newWorld);
743+
ItemPanels.bookmarkPanel.load();
744+
}
741745
}
742746

743747
public static String getWorldPath() {
@@ -838,9 +842,8 @@ public void run() {
838842
});
839843

840844
RecipeCatalysts.loadCatalystInfo();
841-
ItemPanels.bookmarkPanel.load();
842-
SubsetWidget.loadHidden();
843845
CollapsibleItems.load();
846+
SubsetWidget.loadHidden();
844847
ItemSorter.loadConfig();
845848

846849
// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the
@@ -854,10 +857,6 @@ public void run() {
854857
ItemList.loadItems.restart();
855858
}
856859
}.start();
857-
} else {
858-
ItemPanels.bookmarkPanel.load();
859-
SubsetWidget.loadHidden();
860-
ItemList.loadItems.restart();
861860
}
862861
}
863862

src/main/java/codechicken/nei/recipe/StackInfo.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import net.minecraft.nbt.NBTTagCompound;
1111
import net.minecraft.nbt.NBTTagList;
1212
import net.minecraftforge.fluids.FluidContainerRegistry;
13+
import net.minecraftforge.fluids.FluidRegistry;
1314
import net.minecraftforge.fluids.FluidStack;
1415
import net.minecraftforge.fluids.IFluidContainerItem;
1516

@@ -21,6 +22,7 @@
2122

2223
public class StackInfo {
2324

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

3133
@Override
3234
protected boolean removeEldestEntry(Map.Entry<ItemStack, FluidStack> eldest) {
33-
return size() > 20;
35+
return size() > 200;
3436
}
3537
};
3638

@@ -92,7 +94,7 @@ public static boolean equalItemAndNBT(ItemStack stackA, ItemStack stackB, boolea
9294
return true;
9395
}
9496

95-
public static FluidStack getFluid(ItemStack stack) {
97+
public static synchronized FluidStack getFluid(ItemStack stack) {
9698
FluidStack fluid = fluidcache.get(stack);
9799

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

104-
fluidcache.put(stack, fluid);
106+
fluidcache.put(stack, fluid == null ? NULL_FLUID : fluid);
105107
}
106108

107-
return fluid;
109+
return fluid == NULL_FLUID ? null : fluid;
108110
}
109111

110112
public static boolean isFluidContainer(ItemStack stack) {

0 commit comments

Comments
 (0)