Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ repositories {
}

dependencies {
implementation("org.ajoberstar.grgit:grgit-core:4.1.0")
implementation("org.ajoberstar.grgit:grgit-core:5.3.0")
implementation("com.charleskorn.kaml:kaml:0.37.0")
}
22 changes: 14 additions & 8 deletions fabric/src/main/kotlin/FabricGameAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fun toServerWorld(world: World): MCServerWorld {
return (world as MCServerWorld).level
}

private fun toEnchantmentType(mcType: MCEnchantmentType): EnchantmentType {
private fun toEnchantmentType(mcType: MCEnchantmentType): EnchantmentType? {
return when (mcType) {
MCEnchantmentType.ARMOR -> EnchantmentType.ARMOR
MCEnchantmentType.ARMOR_FEET -> EnchantmentType.ARMOR_FEET
Expand All @@ -110,6 +110,7 @@ private fun toEnchantmentType(mcType: MCEnchantmentType): EnchantmentType {
MCEnchantmentType.WEARABLE -> EnchantmentType.WEARABLE
MCEnchantmentType.CROSSBOW -> EnchantmentType.CROSSBOW
MCEnchantmentType.VANISHABLE -> EnchantmentType.VANISHABLE
else -> null
}
}

Expand Down Expand Up @@ -164,13 +165,18 @@ object FabricGameAPI : GameAPI {
)
}

enchantments = BuiltInRegistries.ENCHANTMENT.entrySet().map {
Enchantment(
it.key.location().toString(),
type = toEnchantmentType(it.value.category),
maxLevel = it.value.maxLevel,
isCurse = it.value.isCurse,
)
enchantments = BuiltInRegistries.ENCHANTMENT.entrySet().mapNotNull {
val enchantmentType = toEnchantmentType(it.value.category)
if (enchantmentType == null) {
null
} else {
Enchantment(
it.key.location().toString(),
type = enchantmentType,
maxLevel = it.value.maxLevel,
isCurse = it.value.isCurse,
)
}
}
}

Expand Down
22 changes: 14 additions & 8 deletions forge/src/main/kotlin/ForgeGameAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fun toServerWorld(world: World): MCServerWorld {
return (world as MCServerWorld).level
}

private fun toEnchantmentType(mcType: MCEnchantmentType): EnchantmentType {
private fun toEnchantmentType(mcType: MCEnchantmentType): EnchantmentType? {
return when (mcType) {
MCEnchantmentType.ARMOR -> EnchantmentType.ARMOR
MCEnchantmentType.ARMOR_FEET -> EnchantmentType.ARMOR_FEET
Expand All @@ -106,6 +106,7 @@ private fun toEnchantmentType(mcType: MCEnchantmentType): EnchantmentType {
MCEnchantmentType.WEARABLE -> EnchantmentType.WEARABLE
MCEnchantmentType.CROSSBOW -> EnchantmentType.CROSSBOW
MCEnchantmentType.VANISHABLE -> EnchantmentType.VANISHABLE
else -> null
}
}

Expand Down Expand Up @@ -160,13 +161,18 @@ object ForgeGameAPI : GameAPI {
)
}

enchantments = ForgeRegistries.ENCHANTMENTS.entries.map {
Enchantment(
it.key.location().toString(),
type = toEnchantmentType(it.value.category),
maxLevel = it.value.maxLevel,
isCurse = it.value.isCurse,
)
enchantments = ForgeRegistries.ENCHANTMENTS.entries.mapNotNull {
val enchantmentType = toEnchantmentType(it.value.category)
if (enchantmentType == null) {
null
} else {
Enchantment(
it.key.location().toString(),
type = enchantmentType,
maxLevel = it.value.maxLevel,
isCurse = it.value.isCurse,
)
}
}
}

Expand Down