String drop rate from infested leaves is now configurable

This commit is contained in:
thedarkcolour 2024-02-07 18:23:13 -08:00
parent e565b456fd
commit 9177aea415
2 changed files with 8 additions and 5 deletions

View File

@ -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();
}
}

View File

@ -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;