Skip to content

Commit

Permalink
Add Fabric entrypoint to allow other mods to register providers safely.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Jan 6, 2023
1 parent 452479d commit 40b1ecd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package li.cil.tis3d.api.platform;

/**
* Fabric specific interface, used to define an entrypoint that is invoked when all
* TIS-3D owned registries have been created, and entries may be registered with
* them. This is Fabric's approach to allowing ordered initialization. For Forge this
* is not required, since it allows declaring mod initialization ordering.
*/
public interface FabricProviderInitializer {
/**
* Registers providers with provider registries.
*/
void registerProviders();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package li.cil.tis3d.api.platform;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package li.cil.tis3d.client.fabric;

import li.cil.tis3d.api.platform.FabricProviderInitializer;
import li.cil.tis3d.client.ClientBootstrap;
import li.cil.tis3d.client.ClientSetup;
import li.cil.tis3d.client.renderer.Textures;
Expand All @@ -11,6 +12,7 @@
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.fabricmc.fabric.api.event.client.player.ClientPickBlockGatherCallback;
import net.fabricmc.loader.impl.entrypoint.EntrypointUtils;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BlockEntity;
Expand All @@ -22,6 +24,8 @@ public void onInitializeClient() {
ClientBootstrap.run();
ClientSetup.run();

EntrypointUtils.invoke("tis3d:registration", FabricProviderInitializer.class, FabricProviderInitializer::registerProviders);

ClientChunkEvents.CHUNK_UNLOAD.register((level, chunk) -> {
for (final BlockEntity blockEntity : chunk.getBlockEntities().values()) {
if (blockEntity instanceof final ChunkUnloadListener listener) {
Expand Down

0 comments on commit 40b1ecd

Please sign in to comment.