Compare commits

...
@@ -189,17 +189,26 @@ class PokeRodFishingBobberEntity(type: EntityType<out PokeRodFishingBobberEntity
// Placeholder, will be recalculated
0.0F
} else {
val increase = if (index < baseIncreases.size) baseIncreases[index] else baseIncreases.last() + (index - baseIncreases.size + 1) * 0.15F
// Adjust weights for buckets other than Common
val increase = if (index - 1 < baseIncreases.size) {
baseIncreases[index - 1]
} else {
baseIncreases.last() + (index - baseIncreases.size) * 0.15F
}
bucket.weight + increase * luckOfTheSeaLevel
}
}.toMutableList()
// Recalculate the first bucket's weight to ensure the total is 100%
val totalAdjustedWeight = adjustedWeights.sum() - adjustedWeights[0] // Corrected to ensure the list contains Floats
adjustedWeights[0] = 100.0F - totalAdjustedWeight + buckets[0].weight
val otherWeightsSum = adjustedWeights.drop(1).sum() // Sum of all adjusted weights except the first
adjustedWeights[0] = when {
(100.0F - otherWeightsSum < 0) -> 0F
else -> 100.0F - otherWeightsSum
}
// Random selection based on adjusted weights
val weightSum = adjustedWeights.sum()
val chosenSum = kotlin.random.Random.nextDouble(weightSum.toDouble()).toFloat() // Ensure usage of Random from kotlin.random package
var sum = 0.0F
adjustedWeights.forEachIndexed { index, weight ->