Skip to content

Commit 1560b6a

Browse files
committed
fix tag snippet compiling
1 parent eaa1cb7 commit 1560b6a

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

src/main/java/com/probejs/compiler/SnippetCompiler.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,10 @@
2020

2121
public class SnippetCompiler {
2222

23-
private static SpecialData data;
24-
25-
public static void init(SpecialData data){
26-
SnippetCompiler.data = data;
27-
}
28-
29-
public static JsonObject toSnippet(SpecialData dump) {
23+
public static JsonObject toSnippet() {
3024
JsonObject resultJson = new JsonObject();
3125
// Compile normal entries to snippet
32-
for (RegistryInfo info : dump.registries) {
26+
for (RegistryInfo info : SpecialData.computeRegistryInfos()) {
3327
final String type = info.id.getPath();
3428
final Map<String, List<String>> byModMembers = new HashMap<>();
3529
info.names.forEach(rl ->
@@ -56,7 +50,7 @@ public static JsonObject toSnippet(SpecialData dump) {
5650
}
5751

5852
// Compile tag entries to snippet
59-
for (Map.Entry<String, Collection<ResourceLocation>> entry : dump.tags.entrySet()) {
53+
for (Map.Entry<String, Collection<ResourceLocation>> entry : SpecialData.computeTags().entrySet()) {
6054
String type = entry.getKey();
6155
Map<String, List<String>> byModMembers = new HashMap<>();
6256
entry
@@ -89,11 +83,11 @@ public static void compile() throws IOException {
8983
compileClassNames();
9084
}
9185
Path codeFile = ProbePaths.WORKSPACE.resolve("probe.code-snippets");
92-
9386
BufferedWriter writer = Files.newBufferedWriter(codeFile);
94-
ProbeJS.GSON.toJson(toSnippet(SnippetCompiler.data), writer);
87+
88+
ProbeJS.GSON.toJson(toSnippet(), writer);
89+
9590
writer.close();
96-
SnippetCompiler.data = null;
9791
}
9892

9993
private static void compileClassNames() throws IOException {

src/main/java/com/probejs/compiler/SpecialCompiler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public abstract class SpecialCompiler {
2121
public static void compile(Map<ResourceLocation, RecipeTypeJS> recipeHandlers) throws IOException {
2222
final SpecialData data = SpecialData.fetch();
2323

24-
SnippetCompiler.init(data);
2524
RegistryCompiler.init(data.registries);
2625
TagCompiler.init(data.tags);
2726
RecipeHoldersCompiler.init(recipeHandlers);

src/main/java/com/probejs/info/SpecialData.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ private static void putTag(
3535
target.put(type, tagIds);
3636
}
3737

38-
public static SpecialData fetch() {
38+
public static Map<String, Collection<ResourceLocation>> computeTags() {
3939
final Map<String, Collection<ResourceLocation>> tags = new HashMap<>();
4040
putTag(tags, "items", Tags.items());
4141
putTag(tags, "blocks", Tags.blocks());
4242
putTag(tags, "fluids", Tags.fluids());
4343
putTag(tags, "entity_types", Tags.entityTypes());
44-
return new SpecialData(tags, computeRegistryInfos());
44+
return tags;
45+
}
46+
47+
public static SpecialData fetch() {
48+
return new SpecialData(computeTags(), computeRegistryInfos());
4549
}
4650

4751
@Override

0 commit comments

Comments
 (0)