From ddb044b48d5c0ac9597768b85399614e69032b84 Mon Sep 17 00:00:00 2001 From: Illyrius Date: Mon, 17 Nov 2025 10:20:39 +0100 Subject: [PATCH 1/6] init Signed-off-by: Illyrius --- .../vanillaplus/VanillaPlusBootstrap.kt | 14 ++++++++++++- .../enchantments/NimbusEnchantment.kt | 20 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt diff --git a/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt b/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt index 7c1eb9ad6..fa704d08d 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/VanillaPlusBootstrap.kt @@ -14,6 +14,7 @@ import io.papermc.paper.registry.tag.TagKey import io.papermc.paper.tag.TagEntry import net.kyori.adventure.key.Key import org.xodium.vanillaplus.enchantments.NightVisionEnchantment +import org.xodium.vanillaplus.enchantments.NimbusEnchantment import org.xodium.vanillaplus.enchantments.PickupEnchantment import org.xodium.vanillaplus.enchantments.ReplantEnchantment @@ -81,12 +82,23 @@ internal class VanillaPlusBootstrap : PluginBootstrap { .invoke(builder) .supportedItems(event.getOrCreateTag(ItemTypeTagKeys.HEAD_ARMOR)) } + register(NimbusEnchantment.key) { builder -> + NimbusEnchantment + .invoke(builder) + .supportedItems(event.getOrCreateTag(ItemTypeTagKeys.HARNESSES)) + } } }, ) registerEventHandler(LifecycleEvents.TAGS.postFlatten(RegistryKey.ENCHANTMENT)) { event -> event.registrar().apply { - val enchants = setOf(ReplantEnchantment.key, PickupEnchantment.key, NightVisionEnchantment.key) + val enchants = + setOf( + ReplantEnchantment.key, + PickupEnchantment.key, + NightVisionEnchantment.key, + NimbusEnchantment.key, + ) addToTag(EnchantmentTagKeys.TRADEABLE, enchants) addToTag(EnchantmentTagKeys.NON_TREASURE, enchants) addToTag(EnchantmentTagKeys.IN_ENCHANTING_TABLE, enchants) diff --git a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt new file mode 100644 index 000000000..66a0fa0da --- /dev/null +++ b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt @@ -0,0 +1,20 @@ +package org.xodium.vanillaplus.enchantments + +import io.papermc.paper.registry.data.EnchantmentRegistryEntry +import org.bukkit.inventory.EquipmentSlotGroup +import org.xodium.vanillaplus.interfaces.EnchantmentInterface +import org.xodium.vanillaplus.utils.ExtUtils.mm + +/** Represents an object handling nimbus enchantment implementation within the system. */ +@Suppress("UnstableApiUsage") +internal object NimbusEnchantment : EnchantmentInterface { + override fun invoke(builder: EnchantmentRegistryEntry.Builder): EnchantmentRegistryEntry.Builder = + builder + .description(key.value().replaceFirstChar { it.uppercase() }.mm()) + .anvilCost(2) + .maxLevel(1) + .weight(2) + .minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(25, 0)) + .maximumCost(EnchantmentRegistryEntry.EnchantmentCost.of(75, 0)) + .activeSlots(EquipmentSlotGroup.SADDLE) +} From 9fefb6d9fb51cba895bab2497edb6b03bdb4f4d5 Mon Sep 17 00:00:00 2001 From: Illyrius Date: Mon, 17 Nov 2025 11:24:19 +0100 Subject: [PATCH 2/6] impl Signed-off-by: Illyrius --- .idea/dictionaries/project.xml | 1 + .../enchantments/NimbusEnchantment.kt | 23 +++++++++++++++++++ .../vanillaplus/modules/EntityModule.kt | 9 ++++++++ 3 files changed, 33 insertions(+) diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml index 1b9931fdd..f348421e9 100644 --- a/.idea/dictionaries/project.xml +++ b/.idea/dictionaries/project.xml @@ -14,6 +14,7 @@ fawe foojay ghast + ghasts glorp gradleup griefing diff --git a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt index 66a0fa0da..9efd60848 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt @@ -1,6 +1,10 @@ package org.xodium.vanillaplus.enchantments +import io.papermc.paper.event.entity.EntityEquipmentChangedEvent import io.papermc.paper.registry.data.EnchantmentRegistryEntry +import org.bukkit.attribute.Attribute +import org.bukkit.entity.HappyGhast +import org.bukkit.inventory.EquipmentSlot import org.bukkit.inventory.EquipmentSlotGroup import org.xodium.vanillaplus.interfaces.EnchantmentInterface import org.xodium.vanillaplus.utils.ExtUtils.mm @@ -8,6 +12,10 @@ import org.xodium.vanillaplus.utils.ExtUtils.mm /** Represents an object handling nimbus enchantment implementation within the system. */ @Suppress("UnstableApiUsage") internal object NimbusEnchantment : EnchantmentInterface { + private object DEFAULTS { + const val HAPPY_GHAST_DEFAULT_FLYING_SPEED = 0.05 + } + override fun invoke(builder: EnchantmentRegistryEntry.Builder): EnchantmentRegistryEntry.Builder = builder .description(key.value().replaceFirstChar { it.uppercase() }.mm()) @@ -17,4 +25,19 @@ internal object NimbusEnchantment : EnchantmentInterface { .minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(25, 0)) .maximumCost(EnchantmentRegistryEntry.EnchantmentCost.of(75, 0)) .activeSlots(EquipmentSlotGroup.SADDLE) + + /** + * Handles the event when an entity's equipment changes, specifically for Happy Ghasts with the nimbus enchantment. + * @param event The event representing the change in entity equipment. + */ + fun nimbus(event: EntityEquipmentChangedEvent) { + val entity = event.entity as? HappyGhast ?: return + val harness = entity.equipment.getItem(EquipmentSlot.SADDLE) + + if (harness.hasItemMeta() && harness.itemMeta.hasEnchant(get())) { + entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = 0.1 + } else { + entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = DEFAULTS.HAPPY_GHAST_DEFAULT_FLYING_SPEED + } + } } diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt index 45a49cdf8..cfe49c7d9 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt @@ -2,6 +2,7 @@ package org.xodium.vanillaplus.modules +import io.papermc.paper.event.entity.EntityEquipmentChangedEvent import org.bukkit.Material import org.bukkit.entity.* import org.bukkit.event.EventHandler @@ -9,6 +10,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent import org.bukkit.event.entity.EntityDeathEvent import org.bukkit.event.entity.EntityExplodeEvent import org.bukkit.inventory.ItemStack +import org.xodium.vanillaplus.enchantments.NimbusEnchantment import org.xodium.vanillaplus.interfaces.ModuleInterface import kotlin.random.Random @@ -36,6 +38,13 @@ internal class EntityModule : ModuleInterface { } } + @EventHandler + fun on(event: EntityEquipmentChangedEvent) { + if (!enabled()) return + + NimbusEnchantment.nimbus(event) + } + /** * Determines whether an entity's griefing behaviour should be cancelled based on configuration settings. * @param entity The entity whose griefing behaviour is being evaluated. From 6b16f7e7243e46836b37f849329ede649ffc65c4 Mon Sep 17 00:00:00 2001 From: Illyrius Date: Mon, 17 Nov 2025 11:29:58 +0100 Subject: [PATCH 3/6] feat: adjust Nimbus enchantment flying speed and add TODO for maxLevel implementation Signed-off-by: Illyrius --- .../org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt index 9efd60848..a78f702f3 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt @@ -16,6 +16,7 @@ internal object NimbusEnchantment : EnchantmentInterface { const val HAPPY_GHAST_DEFAULT_FLYING_SPEED = 0.05 } + // TODO: add maxLevel 5 and adjust flying speed accordingly. override fun invoke(builder: EnchantmentRegistryEntry.Builder): EnchantmentRegistryEntry.Builder = builder .description(key.value().replaceFirstChar { it.uppercase() }.mm()) @@ -35,7 +36,7 @@ internal object NimbusEnchantment : EnchantmentInterface { val harness = entity.equipment.getItem(EquipmentSlot.SADDLE) if (harness.hasItemMeta() && harness.itemMeta.hasEnchant(get())) { - entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = 0.1 + entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = 10.0 // TODO: Adjust flying speed value as needed } else { entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = DEFAULTS.HAPPY_GHAST_DEFAULT_FLYING_SPEED } From 08f79c5465a3958a0e6b8eb8a957ec5c3ccb4134 Mon Sep 17 00:00:00 2001 From: Illyrius Date: Mon, 17 Nov 2025 11:35:05 +0100 Subject: [PATCH 4/6] feat: remove unused DEFAULTS object and streamline Nimbus enchantment flying speed logic Signed-off-by: Illyrius --- .../xodium/vanillaplus/enchantments/NimbusEnchantment.kt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt index a78f702f3..b0e80cced 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt @@ -12,10 +12,6 @@ import org.xodium.vanillaplus.utils.ExtUtils.mm /** Represents an object handling nimbus enchantment implementation within the system. */ @Suppress("UnstableApiUsage") internal object NimbusEnchantment : EnchantmentInterface { - private object DEFAULTS { - const val HAPPY_GHAST_DEFAULT_FLYING_SPEED = 0.05 - } - // TODO: add maxLevel 5 and adjust flying speed accordingly. override fun invoke(builder: EnchantmentRegistryEntry.Builder): EnchantmentRegistryEntry.Builder = builder @@ -36,9 +32,9 @@ internal object NimbusEnchantment : EnchantmentInterface { val harness = entity.equipment.getItem(EquipmentSlot.SADDLE) if (harness.hasItemMeta() && harness.itemMeta.hasEnchant(get())) { - entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = 10.0 // TODO: Adjust flying speed value as needed + entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = 10.0 } else { - entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = DEFAULTS.HAPPY_GHAST_DEFAULT_FLYING_SPEED + entity.getAttribute(Attribute.FLYING_SPEED)?.defaultValue } } } From 0b48b161550abb8dfcb9c7282535efd46577109c Mon Sep 17 00:00:00 2001 From: Illyrius Date: Mon, 17 Nov 2025 12:20:18 +0100 Subject: [PATCH 5/6] feat: enhance Nimbus enchantment flying speed logic with level-based multipliers Signed-off-by: Illyrius --- .../enchantments/NimbusEnchantment.kt | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt index b0e80cced..76ee5f719 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt @@ -12,15 +12,16 @@ import org.xodium.vanillaplus.utils.ExtUtils.mm /** Represents an object handling nimbus enchantment implementation within the system. */ @Suppress("UnstableApiUsage") internal object NimbusEnchantment : EnchantmentInterface { - // TODO: add maxLevel 5 and adjust flying speed accordingly. + const val DEFAULT_FLY_SPEED = 0.05 + override fun invoke(builder: EnchantmentRegistryEntry.Builder): EnchantmentRegistryEntry.Builder = builder .description(key.value().replaceFirstChar { it.uppercase() }.mm()) .anvilCost(2) - .maxLevel(1) + .maxLevel(5) .weight(2) - .minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(25, 0)) - .maximumCost(EnchantmentRegistryEntry.EnchantmentCost.of(75, 0)) + .minimumCost(EnchantmentRegistryEntry.EnchantmentCost.of(25, 5)) + .maximumCost(EnchantmentRegistryEntry.EnchantmentCost.of(75, 10)) .activeSlots(EquipmentSlotGroup.SADDLE) /** @@ -29,12 +30,30 @@ internal object NimbusEnchantment : EnchantmentInterface { */ fun nimbus(event: EntityEquipmentChangedEvent) { val entity = event.entity as? HappyGhast ?: return - val harness = entity.equipment.getItem(EquipmentSlot.SADDLE) + val harness = entity.equipment.getItem(EquipmentSlot.BODY) + val attribute = entity.getAttribute(Attribute.FLYING_SPEED) if (harness.hasItemMeta() && harness.itemMeta.hasEnchant(get())) { - entity.getAttribute(Attribute.FLYING_SPEED)?.baseValue = 10.0 + val level = harness.itemMeta.getEnchantLevel(get()) + val speedMultiplier = getSpeedMultiplier(level) + attribute?.baseValue = DEFAULT_FLY_SPEED * speedMultiplier } else { - entity.getAttribute(Attribute.FLYING_SPEED)?.defaultValue + attribute?.baseValue = DEFAULT_FLY_SPEED } } + + /** + * Calculates the flying speed multiplier based on the enchantment level. + * @param level The enchantment level (1-5) + * @return The flying speed multiplier for the given level + */ + private fun getSpeedMultiplier(level: Int): Double = + when (level) { + 1 -> 1.0 + 2 -> 1.5 + 3 -> 2.0 + 4 -> 2.5 + 5 -> 3.0 + else -> 1.0 + } } From 6a5104abe94ef43fe06b399eabc6be5164cdfbf2 Mon Sep 17 00:00:00 2001 From: Illyrius Date: Mon, 17 Nov 2025 12:21:37 +0100 Subject: [PATCH 6/6] feat: update Nimbus enchantment speed multipliers for improved level scaling Signed-off-by: Illyrius --- .../vanillaplus/enchantments/NimbusEnchantment.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt index 76ee5f719..39f6c0660 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/enchantments/NimbusEnchantment.kt @@ -49,11 +49,11 @@ internal object NimbusEnchantment : EnchantmentInterface { */ private fun getSpeedMultiplier(level: Int): Double = when (level) { - 1 -> 1.0 - 2 -> 1.5 - 3 -> 2.0 - 4 -> 2.5 - 5 -> 3.0 + 1 -> 1.5 + 2 -> 2.0 + 3 -> 2.5 + 4 -> 3.0 + 5 -> 3.5 else -> 1.0 } }