Skip to content

Commit

Permalink
Merge branch 'extend_subset_widget' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Dec 31, 2024
2 parents c68ce11 + 27fc0b8 commit 1aa6098
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 54 deletions.
20 changes: 11 additions & 9 deletions src/main/java/codechicken/nei/NEIClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -723,21 +723,22 @@ public static OptionList getOptionList() {

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

if (!worldPath.equals(NEIClientConfig.worldPath)) {
NEIClientConfig.worldPath = worldPath;
setInternalEnabled(true);
logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");

logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World");
final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath);
final boolean newWorld = !specificDir.exists();

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);
ItemPanels.bookmarkPanel.load();
}
}

public static String getWorldPath() {
return NEIClientConfig.worldPath;
Expand Down Expand Up @@ -837,8 +838,9 @@ public void run() {
});

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

// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the
Expand Down
20 changes: 8 additions & 12 deletions src/main/java/codechicken/nei/recipe/StackInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
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 @@ -19,21 +18,19 @@
import codechicken.nei.api.IStackStringifyHandler;
import codechicken.nei.recipe.stackinfo.DefaultStackStringifyHandler;
import codechicken.nei.recipe.stackinfo.GTFluidStackStringifyHandler;
import codechicken.nei.util.ItemStackKey;

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<>();
private static final LinkedHashMap<ItemStackKey, FluidStack> fluidcache = new LinkedHashMap<>() {
private static final LinkedHashMap<ItemStack, FluidStack> fluidcache = new LinkedHashMap<>() {

private static final long serialVersionUID = 1042213947848622164L;

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

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

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

if (fluid == null) {
if (fluid == null && !fluidcache.containsKey(stack)) {

for (int i = stackStringifyHandlers.size() - 1; i >= 0 && fluid == null; i--) {
fluid = stackStringifyHandlers.get(i).getFluid(stack);
}

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

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

public static boolean isFluidContainer(ItemStack stack) {
Expand Down
33 changes: 0 additions & 33 deletions src/main/java/codechicken/nei/util/ItemStackKey.java

This file was deleted.

0 comments on commit 1aa6098

Please sign in to comment.