Skip to content

Commit

Permalink
fix the handlerordering.csv being empty when created (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexdoru authored Dec 1, 2024
1 parent 3f3c179 commit 7471a82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/main/java/codechicken/nei/ClientHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,8 @@

public class ClientHandler {

private static String[] defaultHandlerOrdering = {
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
"# Ordering lines are <handler ID>,<ordering number>.",
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
"# Any handlers that are missing from this file will be assigned to 0.", "# Negative numbers are fine.",
"# If you delete this file, it will be regenerated with all registered handler IDs.", };
private static ClientHandler instance;

private ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
private final ArrayList<EntityItem> SMPmagneticItems = new ArrayList<>();
private World lastworld;
private GuiScreen lastGui;

Expand Down Expand Up @@ -234,17 +227,22 @@ public static void load() {
}

public static void postInit() {
loadHandlerOrdering();
GuiContainerManager.registerReloadResourceListener();
}

public static void loadHandlerOrdering() {
final String COMMA_DELIMITER = ",";
final String[] defaultHandlerOrdering = {
"# Each line in this file should either be a comment (starts with '#') or an ordering.",
"# Ordering lines are <handler ID>,<ordering number>.",
"# Handlers will be sorted in order of number ascending, so smaller numbers first.",
"# Any handlers that are missing from this file will be assigned to 0.", "# Negative numbers are fine.",
"# If you delete this file, it will be regenerated with all registered handler IDs.", };

loadSettingsFile("handlerordering.csv", (file, writer) -> {
List<String> toWrite = Lists.newArrayList(defaultHandlerOrdering);
GuiRecipeTab.handlerMap.keySet().stream().sorted()
.forEach(handlerId -> toWrite.add(String.format("%s,0", handlerId)));
.forEach(handlerId -> toWrite.add(String.format("%s" + COMMA_DELIMITER + "0", handlerId)));
try {
IOUtils.writeLines(toWrite, "\n", writer);
} catch (IOException e) {}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/codechicken/nei/NEIModContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void loadComplete(FMLLoadCompleteEvent event) {
if (CommonUtils.isClient()) {
GuiRecipeTab.loadHandlerInfo();
ClientHandler.loadPluginsList();
ClientHandler.loadHandlerOrdering();
}
}

Expand Down

0 comments on commit 7471a82

Please sign in to comment.