Skip to content

Commit

Permalink
feat: fabric entrypoint for refined storage platform api
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Jun 16, 2024
1 parent d41a5a5 commit dac6458
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.refinedmods.refinedstorage2.platform.api;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.3.13")
public interface RefinedStoragePlugin {
void onPlatformApiAvailable(PlatformApi platformApi);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.refinedmods.refinedstorage2.platform.fabric;

import com.refinedmods.refinedstorage2.platform.api.PlatformApi;
import com.refinedmods.refinedstorage2.platform.api.RefinedStoragePlugin;
import com.refinedmods.refinedstorage2.platform.common.AbstractModInitializer;
import com.refinedmods.refinedstorage2.platform.common.PlatformProxy;
import com.refinedmods.refinedstorage2.platform.common.content.BlockEntities;
Expand Down Expand Up @@ -57,6 +58,7 @@

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;

Expand All @@ -72,6 +74,7 @@
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
import net.fabricmc.fabric.api.transfer.v1.item.InventoryStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.Container;
Expand Down Expand Up @@ -102,6 +105,7 @@

public class ModInitializerImpl extends AbstractModInitializer implements ModInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(ModInitializerImpl.class);
private static final String PLUGIN_ENTRYPOINT_KEY = "refinedstorage_plugin";

@Override
public void onInitialize() {
Expand All @@ -124,6 +128,11 @@ public void onInitialize() {
registerWrenchingEvent();
registerSecurityBlockBreakEvent();

final List<RefinedStoragePlugin> pluginEntrypoints = FabricLoader.getInstance()
.getEntrypoints(PLUGIN_ENTRYPOINT_KEY, RefinedStoragePlugin.class);
LOGGER.debug("Loading {} Refined Storage plugin entrypoints.", pluginEntrypoints.size());
pluginEntrypoints.forEach(plugin -> plugin.onPlatformApiAvailable(PlatformApi.INSTANCE));

LOGGER.debug("Refined Storage 2 has loaded.");
}

Expand Down

0 comments on commit dac6458

Please sign in to comment.