From 3e3c6366f7d013b6a1e2858c162736460e4eac50 Mon Sep 17 00:00:00 2001 From: klikli-dev Date: Wed, 25 Mar 2020 08:32:55 +0100 Subject: [PATCH 1/2] added config for miner spirits --- .../occultism/config/OccultismConfig.java | 71 ++++++++++++++++--- .../occultism/registry/OccultismItems.java | 48 ++++++++----- 2 files changed, 92 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java b/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java index eede22915..43b3830ec 100644 --- a/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java +++ b/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java @@ -26,12 +26,7 @@ import com.github.klikli_dev.occultism.config.value.CachedFloat; import com.github.klikli_dev.occultism.config.value.CachedInt; import com.github.klikli_dev.occultism.config.value.CachedObject; -import com.google.common.collect.ImmutableList; -import net.minecraft.block.Blocks; -import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.OreFeatureConfig; -import net.minecraft.world.gen.placement.CountRangeConfig; -import net.minecraft.world.gen.placement.Placement; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.ForgeConfigSpec; @@ -46,6 +41,7 @@ public class OccultismConfig extends ConfigBase { public final StorageSettings storage; public final WorldGenSettings worldGen; public final RitualSettings rituals; + public final DimensionalMineshaftSettings dimensionalMineshaft; public final ForgeConfigSpec spec; //endregion Fields @@ -55,10 +51,62 @@ public OccultismConfig() { this.storage = new StorageSettings(this, builder); this.worldGen = new WorldGenSettings(this, builder); this.rituals = new RitualSettings(this, builder); + this.dimensionalMineshaft = new DimensionalMineshaftSettings(this, builder); this.spec = builder.build(); } //endregion Initialization + public class DimensionalMineshaftSettings extends ConfigCategoryBase { + //region Fields + public final MinerSpiritSettings minerFoliotUnspecialized; + public final MinerSpiritSettings minerDjinniOres; + //endregion Fields + + //region Initialization + public DimensionalMineshaftSettings(IConfigCache parent, ForgeConfigSpec.Builder builder) { + super(parent, builder); + builder.comment("Dimensional Mineshaft Settings").push("dimensional_mineshaft"); + + this.minerFoliotUnspecialized = + new MinerSpiritSettings("miner_foliot_unspecialized", parent, builder, 400, 1, 1000); + + this.minerDjinniOres = + new MinerSpiritSettings("miner_djinni_ores", parent, builder, 400, 1, 100); + + builder.pop(); + } + + //endregion Initialization + public class MinerSpiritSettings extends ConfigCategoryBase { + //region Fields + public final CachedInt maxMiningTime; + public final CachedInt rollsPerOperation; + public final CachedInt durability; + //endregion Fields + + //region Initialization + public MinerSpiritSettings(String oreName, IConfigCache parent, ForgeConfigSpec.Builder builder, + int maxMiningTime, int rollsPerOperation, int durability) { + super(parent, builder); + builder.comment("Miner Spirit Settings").push(oreName); + + this.maxMiningTime = CachedInt.cache(this, + builder.comment("The amount of time it takes the spirit to perform one mining operation.") + .define("maxMiningTime", maxMiningTime)); + this.rollsPerOperation = CachedInt.cache(this, + builder.comment("The amount of blocks the spirit will obtain per mining operation") + .define("rollsPerOperation", rollsPerOperation)); + this.durability = CachedInt.cache(this, + builder.comment("The amount of mining operations the spirit can perform before breaking.") + .define("durability", durability)); + + builder.pop(); + } + //endregion Initialization + } + + } + public class RitualSettings extends ConfigCategoryBase { //region Fields public final CachedBoolean enableClearWeatherRitual; @@ -153,18 +201,19 @@ public OreGenSettings(IConfigCache parent, ForgeConfigSpec.Builder builder) { List nether = Stream.of("the_nether").collect(Collectors.toList()); this.otherstoneNatural = - new OreSettings("otherstone_natural", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE,7, + new OreSettings("otherstone_natural", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, + 7, 5, 10, 80, this, builder); this.copperOre = - new OreSettings("copper_ore", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE,9, + new OreSettings("copper_ore", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, 9, 20, 20, 64, this, builder); this.silverOre = - new OreSettings("silver_ore", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE,7, + new OreSettings("silver_ore", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, 7, 5, 0, 30, this, builder); this.iesniumOre = - new OreSettings("iesnium_ore", nether, OreFeatureConfig.FillerBlockType.NETHERRACK,3, + new OreSettings("iesnium_ore", nether, OreFeatureConfig.FillerBlockType.NETHERRACK, 3, 10, 10, 128, this, builder); builder.pop(); } @@ -183,7 +232,9 @@ public class OreSettings extends ConfigCategoryBase { //endregion Fields //region Initialization - public OreSettings(String oreName, List dimensionTypes, OreFeatureConfig.FillerBlockType fillerBlockType, int size, int chance, int min, int max, + public OreSettings(String oreName, List dimensionTypes, + OreFeatureConfig.FillerBlockType fillerBlockType, int size, int chance, int min, + int max, IConfigCache parent, ForgeConfigSpec.Builder builder) { super(parent, builder); builder.comment("Ore Settings").push(oreName); diff --git a/src/main/java/com/github/klikli_dev/occultism/registry/OccultismItems.java b/src/main/java/com/github/klikli_dev/occultism/registry/OccultismItems.java index 6657692db..ee746ac41 100644 --- a/src/main/java/com/github/klikli_dev/occultism/registry/OccultismItems.java +++ b/src/main/java/com/github/klikli_dev/occultism/registry/OccultismItems.java @@ -51,8 +51,9 @@ public class OccultismItems { () -> new DebugWandItem(defaultProperties().maxStackSize(1))); public static final RegistryObject DEBUG_FOLIOT_LUMBERJACK = ITEMS.register("debug_foliot_lumberjack", () -> new SummonFoliotLumberjackItem(defaultProperties().maxStackSize(1))); - public static final RegistryObject DEBUG_FOLIOT_TRANSPORT_ITEMS = ITEMS.register("debug_foliot_transport_items", - () -> new SummonFoliotTransportItemsItem(defaultProperties().maxStackSize(1))); + public static final RegistryObject DEBUG_FOLIOT_TRANSPORT_ITEMS = + ITEMS.register("debug_foliot_transport_items", + () -> new SummonFoliotTransportItemsItem(defaultProperties().maxStackSize(1))); public static final RegistryObject DEBUG_FOLIOT_TRADER_ITEM = ITEMS.register("debug_foliot_trader", () -> new SummonFoliotTraderItem(defaultProperties().maxStackSize(1))); public static final RegistryObject DEBUG_DJINNI_MANAGE_MACHINE = ITEMS.register("debug_djinni_manage_machine", @@ -60,11 +61,14 @@ public class OccultismItems { public static final RegistryObject DEBUG_DJINNI_TEST = ITEMS.register("debug_djinni_test", () -> new SummonDjinniTest(defaultProperties().maxStackSize(1))); - public static final RegistryObject SPIRIT_FIRE = ITEMS.register("spirit_fire", () -> new BlockItem(OccultismBlocks.SPIRIT_FIRE.get(), defaultProperties())); + public static final RegistryObject SPIRIT_FIRE = + ITEMS.register("spirit_fire", () -> new BlockItem(OccultismBlocks.SPIRIT_FIRE.get(), defaultProperties())); //Resources - public static final RegistryObject OTHERWORLD_SAPLING_NATURAL = ITEMS.register("otherworld_sapling_natural", - () -> new OtherworldBlockItem(OccultismBlocks.OTHERWORLD_SAPLING_NATURAL.get(), defaultProperties())); + public static final RegistryObject OTHERWORLD_SAPLING_NATURAL = + ITEMS.register("otherworld_sapling_natural", + () -> new OtherworldBlockItem(OccultismBlocks.OTHERWORLD_SAPLING_NATURAL.get(), + defaultProperties())); public static final RegistryObject TALLOW = ITEMS.register("tallow", () -> new Item(defaultProperties())); public static final RegistryObject AFRIT_ESSENCE = ITEMS.register("afrit_essence", @@ -185,7 +189,7 @@ public class OccultismItems { "book_of_binding_afrit", () -> new BookOfBindingItem(defaultProperties().maxStackSize(1))); public static final RegistryObject BOOK_OF_BINDING_BOUND_AFRIT = ITEMS.register( "book_of_binding_bound_afrit", () -> new BookOfBindingBoundItem(defaultProperties().maxStackSize(1))); - public static final RegistryObject BOOK_OF_BINDING_MARID= ITEMS.register( + public static final RegistryObject BOOK_OF_BINDING_MARID = ITEMS.register( "book_of_binding_marid", () -> new BookOfBindingItem(defaultProperties().maxStackSize(1))); public static final RegistryObject BOOK_OF_BINDING_BOUND_MARID = ITEMS.register( "book_of_binding_bound_marid", () -> new BookOfBindingBoundItem(defaultProperties().maxStackSize(1))); @@ -193,18 +197,18 @@ public class OccultismItems { //Foliot public static final RegistryObject BOOK_OF_CALLING_FOLIOT_LUMBERJACK = ITEMS.register("book_of_calling_foliot_lumberjack", - () -> new BookOfCallingLumberjackItem(defaultProperties().maxStackSize(1), - TranslationKeys.BOOK_OF_CALLING_GENERIC + "_foliot")); + () -> new BookOfCallingLumberjackItem(defaultProperties().maxStackSize(1), + TranslationKeys.BOOK_OF_CALLING_GENERIC + "_foliot")); public static final RegistryObject BOOK_OF_CALLING_FOLIOT_TRANSPORT_ITEMS = ITEMS.register("book_of_calling_foliot_transport_items", - () -> new BookOfCallingTransportItems(defaultProperties().maxStackSize(1), - TranslationKeys.BOOK_OF_CALLING_GENERIC + "_foliot")); + () -> new BookOfCallingTransportItems(defaultProperties().maxStackSize(1), + TranslationKeys.BOOK_OF_CALLING_GENERIC + "_foliot")); //Djinn public static final RegistryObject BOOK_OF_CALLING_DJINNI_MANAGE_MACHINE = ITEMS.register("book_of_calling_djinni_manage_machine", - () -> new BookOfCallingManageMachineItem(defaultProperties().maxStackSize(1), - TranslationKeys.BOOK_OF_CALLING_GENERIC + "_djinni")); + () -> new BookOfCallingManageMachineItem(defaultProperties().maxStackSize(1), + TranslationKeys.BOOK_OF_CALLING_GENERIC + "_djinni")); //Armor public static final RegistryObject OTHERWORLD_GOGGLES = ITEMS.register("otherworld_goggles", @@ -224,12 +228,22 @@ public class OccultismItems { () -> new Item(defaultProperties().food(OccultismFoods.DATURA.get()))); //Miner Spirits - public static final RegistryObject MINER_DEBUG_UNSPECIALIZED = ITEMS.register("miner_debug_unspecialized", - () -> new MinerSpiritItem(defaultProperties().maxDamage(10000), 100, 10)); - public static final RegistryObject MINER_FOLIOT_UNSPECIALIZED = ITEMS.register("miner_foliot_unspecialized", - () -> new MinerSpiritItem(defaultProperties().maxDamage(1000), 400, 1)); + public static final RegistryObject MINER_DEBUG_UNSPECIALIZED = + ITEMS.register("miner_debug_unspecialized", + () -> new MinerSpiritItem(defaultProperties().maxDamage(10000), 100, 10)); + public static final RegistryObject MINER_FOLIOT_UNSPECIALIZED = + ITEMS.register("miner_foliot_unspecialized", + () -> new MinerSpiritItem(defaultProperties() + .maxDamage( + Occultism.CONFIG.dimensionalMineshaft.minerFoliotUnspecialized.durability + .get()), + Occultism.CONFIG.dimensionalMineshaft.minerFoliotUnspecialized.maxMiningTime.get(), + Occultism.CONFIG.dimensionalMineshaft.minerFoliotUnspecialized.rollsPerOperation.get())); public static final RegistryObject MINER_DJINNI_ORES = ITEMS.register("miner_djinni_ores", - () -> new MinerSpiritItem(defaultProperties().maxDamage(100), 400, 1)); + () -> new MinerSpiritItem(defaultProperties().maxDamage( + Occultism.CONFIG.dimensionalMineshaft.minerDjinniOres.durability.get()) + , Occultism.CONFIG.dimensionalMineshaft.minerDjinniOres.maxMiningTime.get(), + Occultism.CONFIG.dimensionalMineshaft.minerDjinniOres.rollsPerOperation.get())); //endregion Fields //region Static Methods From 57f1b8039d4145ef350feaa9fcca4a7a0c1e8d9b Mon Sep 17 00:00:00 2001 From: klikli-dev Date: Wed, 25 Mar 2020 08:33:12 +0100 Subject: [PATCH 2/2] adjusted config to use same naming scheme for all variables --- .../klikli_dev/occultism/config/OccultismConfig.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java b/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java index 43b3830ec..a038cd878 100644 --- a/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java +++ b/src/main/java/com/github/klikli_dev/occultism/config/OccultismConfig.java @@ -201,19 +201,19 @@ public OreGenSettings(IConfigCache parent, ForgeConfigSpec.Builder builder) { List nether = Stream.of("the_nether").collect(Collectors.toList()); this.otherstoneNatural = - new OreSettings("otherstone_natural", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, + new OreSettings("otherstoneNatural", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, 7, 5, 10, 80, this, builder); this.copperOre = - new OreSettings("copper_ore", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, 9, + new OreSettings("copperOre", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, 9, 20, 20, 64, this, builder); this.silverOre = - new OreSettings("silver_ore", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, 7, + new OreSettings("silverOre", overworld, OreFeatureConfig.FillerBlockType.NATURAL_STONE, 7, 5, 0, 30, this, builder); this.iesniumOre = - new OreSettings("iesnium_ore", nether, OreFeatureConfig.FillerBlockType.NETHERRACK, 3, + new OreSettings("iesniumOre", nether, OreFeatureConfig.FillerBlockType.NETHERRACK, 3, 10, 10, 128, this, builder); builder.pop(); }