Skip to content

Commit

Permalink
fix #17 and award player with exp orb pickup
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion committed Aug 17, 2024
1 parent 4e0673f commit d4eb7d6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- fix enchantment not enchantable in enchanting table in >=1.20.6
- also award player with exp orb gain stat
- fix crash on tool repair with telekinesis (#17 by f-raZ0R)
8 changes: 4 additions & 4 deletions src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit d4eb7d6

Please sign in to comment.