Skip to content

Commit 66829c7

Browse files
committed
add config
1 parent 6b02efa commit 66829c7

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/main/java/de/dertoaster/crossbowverhaul/CrossbowverhaulMod.java

+6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
import org.apache.logging.log4j.LogManager;
44
import org.apache.logging.log4j.Logger;
55

6+
import de.dertoaster.crossbowverhaul.config.CrossbowverhaulConfigHolder;
67
import de.dertoaster.crossbowverhaul.init.ModEnchantments;
78
import de.dertoaster.crossbowverhaul.init.ModEntityTypes;
89
import de.dertoaster.crossbowverhaul.init.ModItemProperties;
910
import de.dertoaster.crossbowverhaul.init.ModItems;
1011
import net.minecraftforge.eventbus.api.IEventBus;
1112
import net.minecraftforge.eventbus.api.SubscribeEvent;
13+
import net.minecraftforge.fml.ModLoadingContext;
1214
import net.minecraftforge.fml.common.Mod;
1315
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
1416
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
17+
import net.minecraftforge.fml.config.ModConfig;
1518
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
1619
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
1720

@@ -27,6 +30,9 @@ public class CrossbowverhaulMod
2730
public CrossbowverhaulMod() {
2831
IEventBus modbus = FMLJavaModLoadingContext.get().getModEventBus();
2932

33+
//Register config
34+
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CrossbowverhaulConfigHolder.ITEM_CONFIG_SPEC);
35+
3036
//Register items
3137
ModItems.registerToEventBus(modbus);
3238
//Register entities
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package de.dertoaster.crossbowverhaul.config;
2+
3+
import org.apache.commons.lang3.tuple.Pair;
4+
5+
import net.minecraftforge.common.ForgeConfigSpec;
6+
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
7+
8+
public class CrossbowverhaulConfigHolder {
9+
10+
public static class ItemConfig {
11+
private static final boolean allowEnchantmentsOnCrossbow = true;
12+
private static final boolean allowEnchantmentsOnNetheriteCrossbow = true;
13+
private static final boolean modifyMultiShotEnchantment = true;
14+
15+
public final ConfigValue<Boolean> coEnchCrossbow;
16+
public final ConfigValue<Boolean> coEnchNetheriteCrossbow;
17+
public final ConfigValue<Boolean> coModMultishot;
18+
19+
public ItemConfig(ForgeConfigSpec.Builder builder) {
20+
builder.push("co-item");
21+
22+
this.coEnchCrossbow = builder
23+
.comment("Enable enchantments on the crossbow")
24+
.defineInRange("Enable enchants on crossbow", allowEnchantmentsOnCrossbow, true, false, Boolean.class);
25+
26+
this.coEnchNetheriteCrossbow = builder
27+
.comment("Enable enchantments on the netherite crossbow")
28+
.defineInRange("Enable enchants on netherite crossbow", allowEnchantmentsOnNetheriteCrossbow, true, false, Boolean.class);
29+
30+
builder.pop();
31+
32+
builder.push("co-ench");
33+
34+
this.coModMultishot = builder
35+
.comment("Allows multishot to go up to five")
36+
.defineInRange("Modify multishot enchantment", modifyMultiShotEnchantment, true, false, Boolean.class);
37+
38+
builder.pop();
39+
}
40+
41+
}
42+
43+
public static final ItemConfig ITEM_CONFIG;
44+
public static final ForgeConfigSpec ITEM_CONFIG_SPEC;
45+
46+
static {
47+
Pair<ItemConfig, ForgeConfigSpec> itemConfigSpecPair = new ForgeConfigSpec.Builder().configure(ItemConfig::new);
48+
49+
ITEM_CONFIG = itemConfigSpecPair.getLeft();
50+
ITEM_CONFIG_SPEC = itemConfigSpecPair.getRight();
51+
}
52+
53+
}

0 commit comments

Comments
 (0)