From 9177aea4156ffa8596f4881e609b75f49b36d026 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Wed, 7 Feb 2024 18:23:13 -0800 Subject: [PATCH] String drop rate from infested leaves is now configurable --- src/main/java/thedarkcolour/exdeorum/config/EConfig.java | 4 ++++ .../exdeorum/loot/InfestedStringFunction.java | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/thedarkcolour/exdeorum/config/EConfig.java b/src/main/java/thedarkcolour/exdeorum/config/EConfig.java index 76fd968d..1a218973 100644 --- a/src/main/java/thedarkcolour/exdeorum/config/EConfig.java +++ b/src/main/java/thedarkcolour/exdeorum/config/EConfig.java @@ -136,6 +136,7 @@ public class EConfig { public final IntValue mechanicalHammerEnergyStorage; public final IntValue mechanicalHammerEnergyConsumption; public final IntValue sieveIntervalTicks; + public final DoubleValue infestedLeavesStringChance; public Server(ForgeConfigSpec.Builder builder) { builder.comment("Server configuration for Ex Deorum").push("server"); @@ -191,6 +192,9 @@ public class EConfig { this.sieveIntervalTicks = builder .comment("The minimum number of ticks a player must wait between two sifting operations. Only affects sifting by hand. 0 means no limit.") .defineInRange("sieve_interval", 1, 0, Integer.MAX_VALUE); + this.infestedLeavesStringChance = builder + .comment("The chance for infested leaves to drop string. 0 means infested leaves never drop string, 1 means infested leaves always drop string.") + .defineInRange("infested_leaves_string_chance", 0.4, 0.0, 1.0); builder.pop(); } } diff --git a/src/main/java/thedarkcolour/exdeorum/loot/InfestedStringFunction.java b/src/main/java/thedarkcolour/exdeorum/loot/InfestedStringFunction.java index 6738f98e..b78a8c1d 100644 --- a/src/main/java/thedarkcolour/exdeorum/loot/InfestedStringFunction.java +++ b/src/main/java/thedarkcolour/exdeorum/loot/InfestedStringFunction.java @@ -28,13 +28,11 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import thedarkcolour.exdeorum.block.InfestedLeavesBlock; import thedarkcolour.exdeorum.blockentity.InfestedLeavesBlockEntity; +import thedarkcolour.exdeorum.config.EConfig; import thedarkcolour.exdeorum.registry.ELootFunctions; // Sets the correct amount based on the progress of the infested leaves public class InfestedStringFunction extends LootItemConditionalFunction { - // todo move to config - public static final float STRING_CHANCE = 0.4f; - protected InfestedStringFunction(LootItemCondition[] conditions) { super(conditions); } @@ -49,9 +47,10 @@ public class InfestedStringFunction extends LootItemConditionalFunction { var progress = leaves.getProgress(); var rand = context.getRandom(); var count = 0; + var chance = EConfig.SERVER.infestedLeavesStringChance.get(); - if (rand.nextFloat() < progress * STRING_CHANCE) { - if (rand.nextFloat() < progress * STRING_CHANCE / 4f) { + if (rand.nextFloat() < progress * chance) { + if (rand.nextFloat() < progress * chance / 4f) { ++count; } ++count;