Skip to content

Commit

Permalink
Add entrypoint for other mods to use the API.
Browse files Browse the repository at this point in the history
  • Loading branch information
Provismet committed Oct 30, 2023
1 parent 6bd7465 commit 2f920a8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.2+build.1
loader_version=0.14.22

# Mod Properties
mod_version=0.3.1
mod_version=0.4.0
maven_group=com.provismet
archives_base_name=vmc-mc

Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/provismet/vmcmc/ClientVMC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.provismet.vmcmc.api.VmcApi;
import com.provismet.vmcmc.config.Config;
import com.provismet.vmcmc.vmc.CaptureRegistry;
import com.provismet.vmcmc.vmc.PacketSender;
Expand All @@ -26,6 +28,16 @@ public void onInitializeClient () {
PacketSender.initPort(portInfo.getLeft(), portInfo.getRight());
CaptureRegistry.registerStandardEvents();

FabricLoader.getInstance().getEntrypointContainers(MODID, VmcApi.class).forEach(entrypoint -> {
String otherModId = entrypoint.getProvider().getMetadata().getId();
try {
entrypoint.getEntrypoint().onInitializeVMC();
}
catch (Throwable e) {
LOGGER.error("Error caused by mod " + otherModId + " during integration.", e);
}
});

ClientTickEvents.END_CLIENT_TICK.register(client -> {
CaptureRegistry.iterate(client);
});
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/provismet/vmcmc/api/VmcApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.provismet.vmcmc.api;

/**
* Entrypoint for compatibility with VMC-MC.
* Mods that wish to add functionality to this mod should implement this interface and list the class as a "vmc-mc" entrypoint in fabric.mod.json.
*/
public interface VmcApi {
/**
* An initializer only run on the client-side.
*
* Adding blendshapes, VMC related client-ticks, and hooks to blendstores should be handled within this method.
*/
void onInitializeVMC ();
}

0 comments on commit 2f920a8

Please sign in to comment.