cqy9

Make me a Minecraft Plugin for 1.21.11 that optimizes Pearls And Pearl Catches {if you dont know what pearl catching is search on google its like throwing a pearl and then windcharge so you catch the windcharge}

Kodari AI
KodariNov 4 at 6:47 pm 1
PearlCatchOptimizer
Optimizes Ender Pearl throwing and pearl catching mechanics for Minecraft 1.21.11. Enhances wind charge interactions by allowing players to catch wind charges mid-air after throwing a pearl, improving combo fluidity. Features configurable cooldown reductions, precise hitbox detection for pearl catches, and performance-optimized event handling to reduce lag during rapid pearl usage. Includes toggleable settings for catch radius, velocity preservation, and sound/particle feedback on successful catches.

What should the plugin optimize: pearl and wind-charge physics, server performance when many are thrown, or both? If you want physics changes, what should happen when a wind charge catches a pearl?

cqy9

Both, Optimize pearls and pearl catching

Kodari AI
KodariNov 4 at 6:48 pm 1
  • Keep vanilla pearl and wind-charge behavior, with a configurable boost for nearby pearl catches.

  • Process catches only when a wind charge lands, rather than running a continuous scan.

  • Add configuration for the catch radius, boost, and speed limit.

Created PearlOptimizer for 1.21.11. It boosts your nearby pearls after your wind charge lands, with a configurable radius, multiplier, and speed limit. Catch checks run on impact rather than continuously.

cqy9

Optimize ender pearl physics, trajectory interpolation, and collision hitboxes for ultra-low latency. Eliminate garbage collection overhead through efficient tracking, minimize tick-rate desync during fast player movement, and ensure instant, lag-free pearl catches on modern Paper servers.

Kodari AI
KodariNov 4 at 7:06 pm 1
  • Apply the catch adjustment in the impact event instead of scheduling it for a later tick.

  • Cache configuration and use the server’s nearby-entity lookup, without adding a per-tick tracker.

  • Keep vanilla collision and movement handling; a plugin cannot guarantee zero latency or eliminate garbage collection.

Updated pearl catches to apply their velocity adjustment during the impact event, without a scheduled task or per-tick tracker. Configuration values are cached at startup.

Vanilla still handles collision hitboxes and projectile movement. The catch speed cap applies before the wind charge’s vanilla impulse, which may add more velocity. Zero latency and zero garbage collection can’t be guaranteed by a plugin.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 99
src/main/java/com/kodari/pearloptimizer/PearlOptimizer.java
package com.kodari.pearloptimizer;

import org.bukkit.Location;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

public final class PearlOptimizer extends JavaPlugin implements Listener {
    private boolean catchEnabled;
    private double radius;
    private double multiplier;
    private double maxSpeed;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        catchEnabled = getConfig().getBoolean("catch.enabled", true);
        radius = finiteNonNegative(getConfig().getDouble("catch.radius", 3.0), 3.0);
        radius = Math.min(16.0, radius);
        multiplier = finiteNonNegative(getConfig().getDouble("catch.velocity-multiplier", 1.15), 1.15);
        maxSpeed = finiteNonNegative(getConfig().getDouble("catch.max-speed", 4.0), 4.0);
        getServer().getPluginManager().registerEvents(this, this);
    }

    private double finiteNonNegative(double value, double fallback) {
        return Double.isFinite(value) ? Math.max(0.0, value) : fallback;
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onProjectileHit(ProjectileHitEvent event) {
        Projectile charge = event.getEntity();
        if (!catchEnabled
                || !charge.getType().name().equals("WIND_CHARGE")
                || !(charge.getShooter() instanceof Player owner)) {
            return;
        }

        if (radius == 0.0 || maxSpeed == 0.0) {
            return;
        }

        Location impact = charge.getLocation();
        double radiusSquared = radius * radius;
        double maxSpeedSquared = maxSpeed * maxSpeed;
        for (Entity entity : charge.getNearbyEntities(radius, radius, radius)) {
            if (entity instanceof EnderPearl pearl
                    && pearl.getShooter() instanceof Player shooter
                    && shooter.getUniqueId().equals(owner.getUniqueId())
                    && pearl.isValid() && !pearl.isDead()
                    && entity.getLocation().distanceSquared(impact) <= radiusSquared) {
                Vector velocity = pearl.getVelocity().multiply(multiplier);
                if (velocity.lengthSquared() > maxSpeedSquared) {
                    velocity.normalize().multiply(maxSpeed);
                }
                pearl.setVelocity(velocity);
            }
        }
    }
}