diff --git a/gradle.properties b/gradle.properties index 2e68374..f45f76b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,7 +38,7 @@ mod_name=Advanced Arrows # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=All Rights Reserved # The mod version. See https://semver.org/ -mod_version=0.0.4 +mod_version=0.1.0 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/jenny/advancedarrows/advancedArrows.java b/src/main/java/com/jenny/advancedarrows/advancedArrows.java index 5f17681..8cfec46 100644 --- a/src/main/java/com/jenny/advancedarrows/advancedArrows.java +++ b/src/main/java/com/jenny/advancedarrows/advancedArrows.java @@ -1,5 +1,6 @@ package com.jenny.advancedarrows; +import com.jenny.advancedarrows.conditions.conditions; import com.jenny.advancedarrows.config.ConfigClient; import com.jenny.advancedarrows.config.ConfigCommon; import com.jenny.advancedarrows.entities.entities; @@ -28,6 +29,8 @@ public class advancedArrows { public advancedArrows() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ConfigClient.SPEC, "AdvancedArrows-client.toml"); + ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigCommon.SPEC, "AdvancedArrows-common.toml"); modEventBus.addListener(this::commonSetup); @@ -35,10 +38,9 @@ public class advancedArrows { items.register(modEventBus); creativeTab.register(modEventBus); particles.register(modEventBus); + conditions.register(); MinecraftForge.EVENT_BUS.register(this); - ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, ConfigClient.SPEC, "AdvancedArrows-client.toml"); - ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigCommon.SPEC, "AdvancedArrows-common.toml"); } private void commonSetup(final FMLCommonSetupEvent event) { diff --git a/src/main/java/com/jenny/advancedarrows/conditions/ConfigCondition.java b/src/main/java/com/jenny/advancedarrows/conditions/ConfigCondition.java new file mode 100644 index 0000000..dd4403a --- /dev/null +++ b/src/main/java/com/jenny/advancedarrows/conditions/ConfigCondition.java @@ -0,0 +1,38 @@ +package com.jenny.advancedarrows.conditions; + +import com.google.gson.JsonObject; +import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.crafting.conditions.ICondition; +import net.minecraftforge.common.crafting.conditions.IConditionSerializer; + +import static com.jenny.advancedarrows.advancedArrows.MODID; + +public class ConfigCondition implements IConditionSerializer, ICondition { + public ForgeConfigSpec.ConfigValue config; + public String name; + + public ConfigCondition(String name, ForgeConfigSpec.ConfigValue config) { + this.config = config; + this.name = name; + } + + @Override + public void write(JsonObject json, ConfigCondition value) { + } + + @Override + public ConfigCondition read(JsonObject json) { + return this; + } + + @Override + public ResourceLocation getID() { + return new ResourceLocation(MODID, name); + } + + @Override + public boolean test(IContext context) { + return config.get(); + } +} diff --git a/src/main/java/com/jenny/advancedarrows/conditions/conditions.java b/src/main/java/com/jenny/advancedarrows/conditions/conditions.java new file mode 100644 index 0000000..e2b815d --- /dev/null +++ b/src/main/java/com/jenny/advancedarrows/conditions/conditions.java @@ -0,0 +1,17 @@ +package com.jenny.advancedarrows.conditions; + +import com.jenny.advancedarrows.config.ConfigCommon; +import net.minecraftforge.common.crafting.CraftingHelper; + +public class conditions { + public static void register() { + CraftingHelper.register(new ConfigCondition("breaching", ConfigCommon.C_ENABLE_BREACHING)); + CraftingHelper.register(new ConfigCondition("ender", ConfigCommon.C_ENABLE_ENDER)); + CraftingHelper.register(new ConfigCondition("homing", ConfigCommon.C_ENABLE_HOMING)); + CraftingHelper.register(new ConfigCondition("incendiary", ConfigCommon.C_ENABLE_INCENDIARY)); + CraftingHelper.register(new ConfigCondition("kinetic", ConfigCommon.C_ENABLE_KINETIC)); + CraftingHelper.register(new ConfigCondition("ricochet", ConfigCommon.C_ENABLE_RICOCHET)); + CraftingHelper.register(new ConfigCondition("sharpened", ConfigCommon.C_ENABLE_SHARPENED)); + CraftingHelper.register(new ConfigCondition("switch", ConfigCommon.C_ENABLE_SWITCH)); + } +} diff --git a/src/main/java/com/jenny/advancedarrows/config/ConfigCommon.java b/src/main/java/com/jenny/advancedarrows/config/ConfigCommon.java index 006d62c..849779a 100644 --- a/src/main/java/com/jenny/advancedarrows/config/ConfigCommon.java +++ b/src/main/java/com/jenny/advancedarrows/config/ConfigCommon.java @@ -11,11 +11,28 @@ public class ConfigCommon { public static final ForgeConfigSpec SPEC; public static final ForgeConfigSpec.ConfigValue C_AIMBOT_PLAYER; + public static final ForgeConfigSpec.ConfigValue C_ENABLE_BREACHING, C_ENABLE_ENDER, C_ENABLE_HOMING, C_ENABLE_INCENDIARY, C_ENABLE_KINETIC, C_ENABLE_RICOCHET, C_ENABLE_SHARPENED, C_ENABLE_SWITCH; static { C_AIMBOT_PLAYER = BUILDER.comment("allow the homing arrow to target players") .define("homingAtPlayer", false); + C_ENABLE_BREACHING = + BUILDER.define("enableArrowBreaching", true); + C_ENABLE_ENDER = + BUILDER.define("enableArrowEnder", true); + C_ENABLE_HOMING = + BUILDER.define("enableArrowHoming", true); + C_ENABLE_INCENDIARY = + BUILDER.define("enableArrowIncendiary", true); + C_ENABLE_KINETIC = + BUILDER.define("enableArrowKinetic", true); + C_ENABLE_RICOCHET = + BUILDER.define("enableArrowRicochet", true); + C_ENABLE_SHARPENED = + BUILDER.define("enableArrowSharpened", true); + C_ENABLE_SWITCH = + BUILDER.define("enableArrowSwitch", true); SPEC = BUILDER.build(); } diff --git a/src/main/resources/data/advancedarrows/recipes/arrow_breaching.json b/src/main/resources/data/advancedarrows/recipes/arrow_breaching.json index a8b96a3..9541ffe 100644 --- a/src/main/resources/data/advancedarrows/recipes/arrow_breaching.json +++ b/src/main/resources/data/advancedarrows/recipes/arrow_breaching.json @@ -6,10 +6,16 @@ "item": "minecraft:arrow" }, { - "item": "minecraft:iron" + "item": "minecraft:iron_ingot" } ], "result": { "item": "advancedarrows:arrow_breaching" - } + }, + "conditions": [ + { + "type": "advancedarrows:breaching", + "mod": "advancedarrows" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/advancedarrows/recipes/arrow_ender.json b/src/main/resources/data/advancedarrows/recipes/arrow_ender.json index 3e208a4..10e9641 100644 --- a/src/main/resources/data/advancedarrows/recipes/arrow_ender.json +++ b/src/main/resources/data/advancedarrows/recipes/arrow_ender.json @@ -11,5 +11,11 @@ ], "result": { "item": "advancedarrows:arrow_ender" - } + }, + "conditions": [ + { + "type": "advancedarrows:ender", + "mod": "advancedarrows" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/advancedarrows/recipes/arrow_incendiary.json b/src/main/resources/data/advancedarrows/recipes/arrow_incendiary.json index 1309431..9e49eb3 100644 --- a/src/main/resources/data/advancedarrows/recipes/arrow_incendiary.json +++ b/src/main/resources/data/advancedarrows/recipes/arrow_incendiary.json @@ -11,5 +11,11 @@ ], "result": { "item": "advancedarrows:arrow_incendiary" - } + }, + "conditions": [ + { + "type": "advancedarrows:incendiary", + "mod": "advancedarrows" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/advancedarrows/recipes/arrow_kinetic.json b/src/main/resources/data/advancedarrows/recipes/arrow_kinetic.json index 307bfcc..1a464fb 100644 --- a/src/main/resources/data/advancedarrows/recipes/arrow_kinetic.json +++ b/src/main/resources/data/advancedarrows/recipes/arrow_kinetic.json @@ -11,5 +11,11 @@ ], "result": { "item": "advancedarrows:arrow_kinetic" - } + }, + "conditions": [ + { + "type": "advancedarrows:kinetic", + "mod": "advancedarrows" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/advancedarrows/recipes/arrow_ricochet.json b/src/main/resources/data/advancedarrows/recipes/arrow_ricochet.json index ea2d17e..b0f618f 100644 --- a/src/main/resources/data/advancedarrows/recipes/arrow_ricochet.json +++ b/src/main/resources/data/advancedarrows/recipes/arrow_ricochet.json @@ -11,5 +11,11 @@ ], "result": { "item": "advancedarrows:arrow_ricochet" - } + }, + "conditions": [ + { + "type": "advancedarrows:ricochet", + "mod": "advancedarrows" + } + ] } \ No newline at end of file diff --git a/src/main/resources/data/advancedarrows/recipes/arrow_switch.json b/src/main/resources/data/advancedarrows/recipes/arrow_switch.json index 2adce82..e7f45d6 100644 --- a/src/main/resources/data/advancedarrows/recipes/arrow_switch.json +++ b/src/main/resources/data/advancedarrows/recipes/arrow_switch.json @@ -11,5 +11,11 @@ ], "result": { "item": "advancedarrows:arrow_switch" - } + }, + "conditions": [ + { + "type": "advancedarrows:switch", + "mod": "advancedarrows" + } + ] } \ No newline at end of file