Skip to content

Commit

Permalink
Update Enchantment.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
NichtStudioCode committed Jul 2, 2023
1 parent a3706b6 commit 34e1a95
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ internal class VanillaEnchantment(
class EnchantmentBuilder internal constructor(id: ResourceLocation) : RegistryElementBuilder<Enchantment>(NovaRegistries.ENCHANTMENT, id) {

private var maxLevel: Int = 1
private var weight: Int = 10
private var rarity: Int = 10

private var tableLeveRequirement: (Int) -> IntRange = { val min = 1 + it * 10; min..(min + 5) }
private var isTableDiscoverable: Boolean = false
Expand Down Expand Up @@ -240,16 +240,16 @@ class EnchantmentBuilder internal constructor(id: ResourceLocation) : RegistryEl
* - Rare: 2
* - Very rare: 1
*/
fun tableWeight(weight: Int): EnchantmentBuilder {
this.weight = weight
fun rarity(weight: Int): EnchantmentBuilder {
this.rarity = weight
return this
}

/**
* Configures the rarity of this enchantment. Defaults to `Rarity.COMMON`.
*/
fun tableWeight(rarity: Rarity): EnchantmentBuilder {
this.weight = rarity.weight
fun rarity(rarity: Rarity): EnchantmentBuilder {
this.rarity = rarity.weight
return this
}

Expand Down Expand Up @@ -322,7 +322,7 @@ class EnchantmentBuilder internal constructor(id: ResourceLocation) : RegistryEl
if (isCurse && maxLevel > 1)
throw IllegalArgumentException("Curse enchantments cannot have multiple levels")

val enchantment = NovaEnchantment(id, 1, maxLevel, weight, isTableDiscoverable, isTreasure, isTradeable, isCurse, tableLeveRequirement, compatibility)
val enchantment = NovaEnchantment(id, 1, maxLevel, rarity, isTableDiscoverable, isTreasure, isTradeable, isCurse, tableLeveRequirement, compatibility)
for (category in categories) category.enchantments += enchantment
return enchantment
}
Expand Down

0 comments on commit 34e1a95

Please sign in to comment.