Skip to content

Commit

Permalink
feat: Useful mod checking methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Jan 17, 2025
1 parent aa9dbf9 commit 642f161
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.debug=false


# Version
mod_version=1.2.16
mod_version=1.2.17

# Mod
mod_id=zenith
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/net/zepalesque/zenith/core/Zenith.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModList;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.loading.LoadingModList;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
Expand Down Expand Up @@ -143,6 +145,18 @@ public static ResourceLocation loc(String path) {
return ResourceLocation.fromNamespaceAndPath(MODID, path);
}

public static boolean loaded(String modid) {
return ModList.get().isLoaded(modid);
}

public static boolean loaded(String modid, boolean isEarly) {
return isEarly ? modFileExists(modid) : loaded(modid);
}

public static boolean modFileExists(String modid) {
return LoadingModList.get().getModFileById(modid) != null;
}

public static class Keys {

public static final ResourceKey<Registry<MapCodec<? extends Condition<?>>>> CONDITION_ELEMENT = ResourceKey.createRegistryKey(Zenith.loc("condition_element"));
Expand Down

0 comments on commit 642f161

Please sign in to comment.