From 4488c5b938c3a5be43e63a467d3985f048f8c518 Mon Sep 17 00:00:00 2001 From: cech12 Date: Tue, 22 Sep 2020 09:47:38 +0200 Subject: [PATCH] add a config for adding a curios head slot (default false) #32 --- gradle.properties | 2 +- src/main/java/cech12/usefulhats/UsefulHatsMod.java | 7 +++++++ .../java/cech12/usefulhats/compat/CuriosMod.java | 14 +++++++++++++- src/main/java/cech12/usefulhats/config/Config.java | 8 ++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index af5d5fa..a434a89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=1.8.3 +mod_version=1.8.4 minecraft_version=1.14.4 forge_version=1.14.4-28.1.0 diff --git a/src/main/java/cech12/usefulhats/UsefulHatsMod.java b/src/main/java/cech12/usefulhats/UsefulHatsMod.java index 9bf70ce..f19016d 100644 --- a/src/main/java/cech12/usefulhats/UsefulHatsMod.java +++ b/src/main/java/cech12/usefulhats/UsefulHatsMod.java @@ -2,6 +2,7 @@ import cech12.usefulhats.client.UsefulHatLayer; import cech12.usefulhats.client.UsefulHatModel; +import cech12.usefulhats.compat.CuriosMod; import cech12.usefulhats.config.Config; import cech12.usefulhats.helper.UsefulHatsRecipeSerializers; import cech12.usefulhats.init.ModItems; @@ -14,6 +15,7 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; +import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import static cech12.usefulhats.UsefulHatsMod.MOD_ID; @@ -31,6 +33,11 @@ public UsefulHatsMod() { FMLJavaModLoadingContext.get().getModEventBus().register(new UsefulHatsRecipeSerializers()); } + @SubscribeEvent + public static void sendImc(InterModEnqueueEvent evt) { + CuriosMod.addHeadSlot(); + } + @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void onClientRegister(FMLClientSetupEvent event) { diff --git a/src/main/java/cech12/usefulhats/compat/CuriosMod.java b/src/main/java/cech12/usefulhats/compat/CuriosMod.java index 23a2240..35dab5e 100644 --- a/src/main/java/cech12/usefulhats/compat/CuriosMod.java +++ b/src/main/java/cech12/usefulhats/compat/CuriosMod.java @@ -1,13 +1,25 @@ package cech12.usefulhats.compat; +import cech12.usefulhats.config.Config; +import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.ModList; +import top.theillusivec4.curios.api.CuriosAPI; +import top.theillusivec4.curios.api.imc.CurioIMCMessage; public class CuriosMod { + public static final String CURIOS_ID = "curios"; + private CuriosMod() {} public static boolean isLoaded() { - return ModList.get().isLoaded("curios"); + return ModList.get().isLoaded(CURIOS_ID); + } + + public static void addHeadSlot() { + if (isLoaded() && Config.CURIOS_ADD_HEAD_SLOT.getValue()) { + InterModComms.sendTo(CURIOS_ID, CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("head")); + } } } diff --git a/src/main/java/cech12/usefulhats/config/Config.java b/src/main/java/cech12/usefulhats/config/Config.java index 30916f5..19819f8 100644 --- a/src/main/java/cech12/usefulhats/config/Config.java +++ b/src/main/java/cech12/usefulhats/config/Config.java @@ -12,6 +12,7 @@ public class Config { public static final ConfigType.Boolean BAUBLES_ENABLED = new ConfigType.Boolean(true); public static final ConfigType.Boolean CURIOS_ENABLED = new ConfigType.Boolean(true); + public static final ConfigType.Boolean CURIOS_ADD_HEAD_SLOT = new ConfigType.Boolean(false); public static final ConfigType.Boolean AQUANAUT_HELMET_ENABLED = new ConfigType.Boolean(true); public static final ConfigType.Boolean AQUANAUT_HELMET_DAMAGE_ENABLED = new ConfigType.Boolean(true); @@ -95,11 +96,14 @@ public class Config { common.comment("Some configs in relation to other mods.").push("Compatibility option"); BAUBLES_ENABLED.configObj = common - .comment("Whether or not hats from this mod should be placeable in Baubles head slots.") + .comment("Whether or not hats from this mod should be placeable in Baubles head slot if Baubles is installed.") .define("baublesEnabled", BAUBLES_ENABLED.getDefaultValue()); CURIOS_ENABLED.configObj = common - .comment("Whether or not hats from this mod should be placeable in Curios head slots.") + .comment("Whether or not hats from this mod should be placeable in Curios head slots if Curios is installed.") .define("curiosEnabled", CURIOS_ENABLED.getDefaultValue()); + CURIOS_ADD_HEAD_SLOT.configObj = common + .comment("Whether or not a Curios head slot should be added if Curios is installed.") + .define("curiosAddHeadSlot", CURIOS_ADD_HEAD_SLOT.getDefaultValue()); common.pop();