Skip to content

Commit

Permalink
register contents at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ZZZank committed Jun 5, 2024
1 parent 3538e64 commit ce536ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions common/src/main/java/dev/latvian/kubejs/KubeJS.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dev.latvian.kubejs.net.KubeJSNet;
import dev.latvian.kubejs.player.KubeJSPlayerEventHandler;
import dev.latvian.kubejs.recipe.KubeJSRecipeEventHandler;
import dev.latvian.kubejs.registry.RegistryInfo;
import dev.latvian.kubejs.script.ScriptFileInfo;
import dev.latvian.kubejs.script.ScriptManager;
import dev.latvian.kubejs.script.ScriptPack;
Expand Down Expand Up @@ -135,6 +136,8 @@ public KubeJS() throws Throwable {
KubeJSServerEventHandler.init();
KubeJSRecipeEventHandler.init();

RegistryInfo.MAP.values().forEach(RegistryInfo::registerArch);

PROXY.init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ public String toString() {
return key.location().toString();
}

public int registerArch() {
return registerObjects(this.getArchRegistry()::registerSupplied);
}

public int registerObjects(RegistryCallback<T> function) {
if (CommonProperties.get().debugInfo) {
if (objects.isEmpty()) {
Expand Down
14 changes: 12 additions & 2 deletions forge/src/main/java/dev/latvian/kubejs/forge/KubeJSForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -39,8 +41,12 @@
@Mod(KubeJS.MOD_ID)
public class KubeJSForge {
public KubeJSForge() throws Throwable {
EventBuses.registerModEventBus(KubeJS.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
FMLJavaModLoadingContext.get().getModEventBus().addListener(KubeJSForge::loadComplete);
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();

EventBuses.registerModEventBus(KubeJS.MOD_ID, bus);
bus.addListener(KubeJSForge::loadComplete);
//bus.addGenericListener(Block.class, EventPriority.LOW, KubeJSForge::initRegistries);

KubeJS.instance = new KubeJS();
KubeJS.instance.setup();
IntegrationManager.init();
Expand All @@ -65,6 +71,10 @@ public KubeJSForge() throws Throwable {
CraftingHelper.register(new ResourceLocation("kubejs", "ignore_nbt"), IgnoreNBTIngredient.SERIALIZER);
}

private static void initRegistries(RegistryEvent.Register<Block> event) {
//KubeJS.LOGGER.info("registering");
}

private static void loadComplete(FMLLoadCompleteEvent event) {
KubeJS.instance.loadComplete();
}
Expand Down

0 comments on commit ce536ba

Please sign in to comment.