diff --git a/build.gradle.kts b/build.gradle.kts index d72299b..e630e84 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ plugins { } val beta: Int? = null // Pattern is '1.0.0-beta1-1.20.6-pre.2' -val featureVersion = "3.0.3${if (beta != null) "-beta$beta" else ""}" +val featureVersion = "3.0.4${if (beta != null) "-beta$beta" else ""}" val mcVersion = property("mcVersion")!!.toString() val mcVersionRange = property("mcVersionRange")!!.toString() version = "$featureVersion-$mcVersion" diff --git a/changelog.md b/changelog.md index fa9ebf3..d336c49 100644 --- a/changelog.md +++ b/changelog.md @@ -1 +1,2 @@ -- fix enchantment not enchantable in enchanting table in >=1.20.6 \ No newline at end of file +- also award player with exp orb gain stat +- fix crash on tool repair with telekinesis (#17 by f-raZ0R) \ No newline at end of file diff --git a/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt b/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt index f2ae14c..61e0a0e 100644 --- a/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt +++ b/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt @@ -19,17 +19,17 @@ object DropEvent { } } - @Suppress("unused") + @Suppress("unused", "KotlinConstantConditions") private val listener = event.register { items, exp, player, tool -> if (config.needSneak && !player.isCrouching) return@register if (config.needEnchantment && /*? if >=1.21 {*/ !EnchantmentHelper.hasTag(tool, telekinesisEffectId)/*?} else {*/ /*EnchantmentHelper.getItemEnchantmentLevel(telekinesis, tool) == 0 *//*?}*/) return@register if (config.itemsAllowed) items.removeIf(player::addItem) if (config.expAllowed) { - val fakeExperienceOrb = ExperienceOrb(player.level(), 0.0, 0.0, 0.0, 0) - @Suppress("KotlinConstantConditions") + val fakeExperienceOrb = ExperienceOrb(player.level(), 0.0, 0.0, 0.0, exp.value) + player.take(fakeExperienceOrb, 1) val leftExp = (fakeExperienceOrb as ExperienceOrbInvoker).invokeRepairPlayerItems(player, exp.value) - player.giveExperiencePoints(leftExp) + if (leftExp > 0) player.giveExperiencePoints(leftExp) exp.setValue(0) } }