Skip to content

Commit

Permalink
fixed kubejs crash on server
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Apr 16, 2023
1 parent c211f85 commit c728f9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import muramasa.antimatter.event.ProvidersEvent;
import muramasa.antimatter.event.WorldGenEvent;
import muramasa.antimatter.integration.kubejs.AMWorldEvent;
import muramasa.antimatter.integration.kubejs.KubeJSRegistrar;
import muramasa.antimatter.integration.kubejs.RecipeLoaderEventKubeJS;
import muramasa.antimatter.material.Material;
import muramasa.antimatter.recipe.IRecipe;
Expand Down Expand Up @@ -229,6 +230,7 @@ public static void onResourceReload(boolean serverEvent) {
AntimatterAPI.all(RecipeMap.class, RecipeMap::reset);
final Set<ResourceLocation> filter;
if (AntimatterAPI.isModLoaded(Ref.MOD_KJS)) {
if (serverEvent) KubeJSRegistrar.checkKubeJSServerScriptManager();
RecipeLoaderEventKubeJS ev = RecipeLoaderEventKubeJS.createAndPost(serverEvent);
filter = ev.forLoaders;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package muramasa.antimatter.integration.kubejs;

import dev.latvian.mods.kubejs.KubeJSPaths;
import dev.latvian.mods.kubejs.server.ServerScriptManager;
import muramasa.antimatter.datagen.AntimatterDynamics;
import muramasa.antimatter.AntimatterMod;
import muramasa.antimatter.Ref;
Expand All @@ -9,7 +11,8 @@
import muramasa.antimatter.registration.Side;
import muramasa.antimatter.util.AntimatterPlatformUtils;

;
;import java.nio.file.Files;
import java.nio.file.LinkOption;

public class KubeJSRegistrar extends AntimatterMod {
public KubeJSRegistrar() {
Expand Down Expand Up @@ -53,4 +56,18 @@ public void onRegistrationEvent(RegistrationEvent event, Side side) {
public int getPriority() {
return Integer.MIN_VALUE;
}

public static void checkKubeJSServerScriptManager(){
if (ServerScriptManager.instance == null){
ServerScriptManager.instance = new ServerScriptManager();
try {
if (Files.notExists(KubeJSPaths.DATA, new LinkOption[0])) {
Files.createDirectories(KubeJSPaths.DATA);
}

} catch (Throwable var3) {
throw new RuntimeException("KubeJS failed to register it's script loader!", var3);
}
}
}
}

0 comments on commit c728f9e

Please sign in to comment.