mega_kn1ght_
๐Ÿ“Ž 1 file 12,213 chars
๐Ÿ“„
pasted-code-1794539055454.txt
txt 257 lines
โ–ถ
# Enchain SMP โ€” Complete Plugin Development

Develop and maintain **Enchain SMP**, a custom enchantment plugin for Paper 1.21.11 using Java 25.

The goal is to make all 43 vanilla enchantments work on any applicable item, including normally incompatible combinations. Enchantments must have real functionality, not just appear in item lore.

Preserve vanilla behavior wherever possible unless a custom rule below overrides it.

## 1. Universal Enchantment System

- Allow all 43 vanilla enchantments on any item.
- Allow incompatible enchantments together.
- Make enchantments function on their applicable items, projectiles, mobs, and players.
- Do not restrict enchantments to their normal vanilla item types.
- Preserve item names, lore, attributes, model data, durability, and other existing properties.
- Avoid duplicate effects from multiple event handlers.
- Make enchantments work together without cancelling each other's effects.

Support all 43 enchantments:

Sharpness, Smite, Bane of Arthropods, Fire Aspect, Knockback, Looting, Sweeping Edge, Impaling, Density, Breach, Wind Burst, Power, Punch, Flame, Infinity, Multishot, Piercing, Quick Charge, Channeling, Loyalty, Riptide, Lunge, Efficiency, Fortune, Silk Touch, Aqua Affinity, Protection, Blast Protection, Fire Protection, Projectile Protection, Feather Falling, Thorns, Respiration, Depth Strider, Frost Walker, Soul Speed, Swift Sneak, Luck of the Sea, Lure, Mending, Unbreaking, Curse of Binding, Curse of Vanishing.

## 2. Custom Enchantment Behavior

### Combat enchantments
- Sharpness: increases attack damage.
- Smite: deals extra damage to undead mobs.
- Bane of Arthropods: deals extra damage to arthropods and applies Slowness IV.
- Fire Aspect and Flame: set targets on fire. Both must work on melee and projectile attacks.
- Knockback: increases knockback strength.
- Looting: increases mob drops.
- Sweeping Edge: increases sweeping attack damage.
- Impaling: increases damage against ALL mobs, not just aquatic mobs.
- Power: increases projectile damage.
- Punch: increases projectile knockback.
- Piercing: projectiles pass through multiple entities. Attacks bypass shields completely.
- Channeling: summons lightning at the target or projectile impact, regardless of weather.

### Density V
- Adds 0.5 damage per fallen block per enchantment level.
- Grants full Mace smash mechanics to any enchanted item.
- Must work independently of Breach and Wind Burst.

### Breach IV
- Each level reduces the target's effective armor and armor toughness by 15%.
- Maximum reduction is 60%.
- Grants Mace smash mechanics to non-projectile items.
- Projectiles only receive the armor and toughness reduction, not the Mace smash effect.

### Wind Burst III
- Independently grants full Mace smash mechanics.
- Must not require Density or Breach.
- On a successful smash, launch the player straight upward.
- Knock back nearby entities.
- Allow chained Mace smashes.
- Projectile hits launch the target upward.
- Use the requested vanilla particles and effects described later.

### Infinity I
- Any enchanted item with Infinity never decreases in quantity when used.
- Applies to blocks, food, spawn eggs, potions, pearls, arrows, fireworks, crossbows, and other usable items.
- Totems of Undying must immediately return after activation.
- Infinity on crossbows must regenerate the ammunition, NOT the crossbow itself.
- Restore the exact ammunition type that was fired.
- Regeneration must be instant.
- Preserve the original ammunition slot where possible, including offhand ammunition.
- Never duplicate or lose ammunition.

### Multishot I
- One successful hit can hit up to three targets total: the original target and up to two nearby targets.
- Must work with every supported projectile type, not just arrows.
- Must work against both mobs and players.
- Do not require three projectiles for the effect.
- Preserve the existing working Multishot behavior.

### Quick Charge III
- Reduces projectile weapon loading and charging time.

### Loyalty III
- Thrown items return to their owner.

### Riptide III
- Grants Riptide activation to any enchanted item.
- Non-trident items do not require water or rain.
- Actual tridents must still require water or rain.
- Use a fixed 0.5-second activation delay.
- Remove the Riptide charge animation entirely.
- After the delay, perform the Riptide launch with spinning animation, particles, and sounds.
- Higher levels increase launch strength.
- Riptide must work together with Mace enchantments.
- Set the Riptide cooldown to 0.3 seconds.
- Preserve normal trident behavior outside the custom Riptide system.

### Lunge III
- Every left-click launches the player horizontally in the direction they are looking.
- Works even when clicking air or not hitting an entity.
- Higher levels increase launch distance and strength.
- Consume exactly one hunger point and one durability per activation.
- Consume saturation before hunger.
- Add a 0.5-second cooldown between lunges.
- Use these sounds in sequence:
  - First lunge: `minecraft:item.spear.lunge_1`
  - Second lunge: `minecraft:item.spear.lunge_2`
  - Third lunge: `minecraft:item.spear.lunge_3`
- When hitting a mob or player while lunging, play `minecraft:item.spear.hit`.
- A successful lunge hit deals exactly 3 damage regardless of the target's armor.
- Support attribute swapping while lunging.
- Preserve normal spear Jab cooldown behavior where applicable.

### Efficiency V
- Increases mining speed on mining tools.
- Increases attack speed on combat weapons.
- For projectile weapons and applicable projectile items, each level adds exactly one extra projectile.
- Efficiency V produces five additional projectiles.
- Release each additional projectile 0.3 seconds apart.
- Additional projectiles must spawn at the player's position and travel in the direction the player is currently looking.
- Each projectile must have its own trajectory.
- Do not make extra projectiles follow the original projectile's landing position.
- Firework projectiles must travel horizontally in the player's look direction, not upward.
- Must work with every supported projectile, including arrows, spectral arrows, tridents, fireworks, snowballs, eggs, splash potions, lingering potions, and other vanilla projectiles.
- Items without Efficiency must retain their normal projectile behavior.

### Blast Protection IV
- Custom projectile-only effect.
- When an affected projectile lands, create a large meteor-like crater.
- Increase crater size.
- Optimize block updates to prevent server lag.
- Do not apply this custom crater effect to ordinary non-projectile items.

### Other enchantments
- Fortune: increases applicable block drops.
- Silk Touch: drops the block itself.
- Aqua Affinity: removes underwater mining penalties.
- Protection: reduces most incoming damage.
- Fire Protection: reduces fire damage and burning duration.
- Projectile Protection: reduces projectile damage.
- Feather Falling: reduces fall damage.
- Thorns: damages attackers.
- Respiration: allows longer underwater breathing.
- Depth Strider: increases underwater movement speed.
- Frost Walker: freezes nearby water.
- Soul Speed: increases movement speed on soul blocks.
- Swift Sneak: increases sneaking speed.
- Luck of the Sea: increases fishing treasure chances.
- Lure: reduces fishing bite wait time.
- Mending: uses XP to repair items.
- Unbreaking: reduces durability loss.
- Curse of Binding: prevents normal removal of equipped items.
- Curse of Vanishing: removes the item on death.

## 3. Mace Smash System

Density, Breach, and Wind Burst must each independently activate full Mace smash mechanics when applied to supported non-projectile items.

Requirements:
- Detect falling attacks and calculate fall-based smash damage.
- Apply actual Mace smash damage calculations.
- Use the Mace smash sound, particles, and knockback.
- Stop downward movement for approximately 0.5 seconds after a successful smash to prevent downward glitching.
- Density must correctly add its fall-based damage.
- Wind Burst must launch the player straight upward, not forward or diagonally upward.
- Wind Burst must allow chained smashes.
- Riptide and Mace smash enchantments must work together.
- On actual Mace items, preserve normal vanilla Mace mechanics.

### Mace Smash Boots
Boots enchanted with Density, Breach, or Wind Burst must automatically perform a Mace smash when the player falls onto an entity.

- No left-click or attack input is required.
- Detect enchantments from equipped boots, not just the held item.
- Apply full Mace damage and fall calculations.
- Apply normal Mace knockback, sounds, and particles.
- Wind Burst launches the player straight upward.
- Works against both mobs and players.
- Prevent accidental repeated smash triggers from one landing.

### Mace Effects
- Wind Burst particles: `minecraft:gust_emitter_large`.
- Wind Burst effect: `Effect.Smash_attack`.
- Density and Breach without Wind Burst: use `Effect.Smash_attack` only.
- Do not apply the Wind Burst particle effect to Density or Breach alone.

## 4. Projectile Compatibility

Every applicable projectile enchantment must work with all supported vanilla projectile types.

Support:
- Normal arrows.
- Spectral arrows.
- Tridents.
- Crossbow fireworks.
- Snowballs.
- Eggs.
- Splash potions.
- Lingering potions.
- Other vanilla projectile entities.

Requirements:
- Projectile enchantments must retain their custom behavior regardless of projectile type.
- Fire Aspect and Flame must work on applicable projectile hits.
- Power and Punch must work on applicable projectiles.
- Piercing must work on applicable projectiles.
- Multishot must work on every supported projectile.
- Efficiency must work on every supported projectile.
- Blast Protection's custom crater effect must work on applicable projectile impacts.
- Channeling must work on projectile impacts.
- Support both mobs and players as targets.

Do not assume every projectile uses arrow-specific events or mechanics. Handle projectile-specific behavior properly.

## 5. Shield Bypass

- Melee attacks with Piercing must bypass shields 100%.
- Supported projectiles with Piercing must bypass shields 100%.
- Do not rely only on vanilla arrow Piercing behavior.
- Handle projectile-specific collision and damage behavior.
- Ensure shield bypass works against both mobs and players where applicable.

## 6. Anvil System

Anvils must fully support the custom enchantment system.

- Enchantments applied through anvils must actually remain on the output item.
- Preserve all existing enchantments.
- Preserve incompatible enchantment combinations.
- Preserve item properties and metadata.
- Correctly calculate enchantment levels.
- Never accidentally increase an enchantment level beyond the intended result.
- Example: Efficiency IV + Efficiency V must produce Efficiency V, not Efficiency VI.
- Apply correct level calculations to all enchantments.
- Do not lose enchantments when combining items.

## 7. Enchanting Table

Completely disable the enchanting table.

Anvils must remain usable.

## 8. General Requirements

- Target Paper 1.21.11 and Java 25.
- Use proper Paper APIs wherever possible.
- All enchantments must work on applicable items, mobs, players, and supported projectiles.
- Support normally incompatible enchantments together.
- Preserve vanilla behavior unless a custom rule explicitly changes it.
- Preserve existing working features.
- Prevent duplicate damage, duplicated projectiles, duplicated drops, and duplicated enchantment effects.
- Handle player and mob targets consistently.
- Handle inventory updates safely.
- Prevent item duplication or accidental item deletion.
- Optimize repeating tasks and projectile handling to avoid unnecessary server load.
- Do not use hardcoded assumptions that only work for arrows or swords.
- Fix underlying implementation problems instead of adding temporary workarounds.
- Keep the code organized and maintainable.
- Do not remove existing functionality while implementing new features.

Implement the complete system as one consistent plugin. Do not leave enchantments as visual-only features or implement only a subset of the requirements.
Kodari AI
KodariNov 13 at 3:04 am 3
EnchainSMP
A comprehensive custom enchantment plugin for Paper 1.21.11 that makes all 43 vanilla enchantments universally applicable across any item type. Features include full Mace smash mechanics triggered by Density, Breach, or Wind Burst, custom projectile behavior for all supported projectile types, shield bypass with Piercing, Infinity ammunition regeneration, Multishot multi-target hits, Riptide activation without water, Lunge launch mechanics, Efficiency multi-projectile firing, and Blast Protection crater creation. The plugin preserves vanilla behavior while enabling incompatible enchantment combinations, supports anvil combining with correct level calculations, and disables the enchanting table entirely.

Created the Paper 1.21.11 project with enchanting tables disabled and an initial anvil enchantment-merging implementation.

The requested system is not complete. Custom combat, projectile, movement, Infinity, and mace mechanics are not implemented, and the anvil implementation has not been verified. Do not use it on a production server yet.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 121
src/main/java/com/enchainsmp/EnchainSMP.java
package com.enchainsmp;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

public final class EnchainSMP extends JavaPlugin {
    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(new EnchantmentAnvil(), this);
    }
}