Tapio Tuoriniemi

fishing rod that can catch any item in the game and enchant name mob catcher if you enchant fishing rod whit mob catcher you can get any entity

Kodari AI
KodariOct 8 at 4:46 pm 1
MobCatcher
A Minecraft plugin introducing a special fishing rod enchantment called "Mob Catcher." When applied to a fishing rod, this enchantment transforms fishing gameplay, allowing players to catch any entity in the game instead of just fish. The plugin intercepts fishing events, checks for the enchantment level, and replaces standard fish loot with a random mob spawn egg or directly spawns the caught entity. It supports catching passive mobs, hostile mobs, and even rare boss entities, with configurable drop rates and entity blacklists. Players can also catch items, making the rod a versatile tool for collecting resources and creatures. The plugin includes a custom enchantment registration, event listeners for fishing and hook interactions, and a configuration file for customizing catch probabilities and allowed entities.
  1. Add the Paper project setup and /mobcatcher command.

  2. Implement the custom rod to collect dropped items and capture/release entities.

Added the Mob Catcher fishing rod. Use /mobcatcher to get one; it catches dropped items and turns hooked non-player entities into tokens you can right-click to release. The custom enchant is applied through the command rather than the vanilla enchanting table.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
4 258
src/main/java/com/kodari/mobcatcher/MobCatcherPlugin.java
package com.kodari.mobcatcher;

import com.cryptomorin.xseries.XEnchantment;
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.List;

public final class MobCatcherPlugin extends JavaPlugin implements CommandExecutor {
    private NamespacedKey rodKey;

    @Override
    public void onEnable() {
        rodKey = new NamespacedKey(this, "mob_catcher_rod");
        getServer().getPluginManager().registerEvents(new MobCatcherListener(this, rodKey), this);
        getCommand("mobcatcher").setExecutor(this);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("This command can only be used by a player.");
            return true;
        }

        Material rodMaterial = XMaterial.matchXMaterial("FISHING_ROD")
                .map(XMaterial::parseMaterial)
                .orElse(null);
        if (rodMaterial == null) {
            player.sendMessage(ChatColor.RED + "Fishing rods are unavailable on this server version.");
            return true;
        }

        ItemStack rod = new ItemStack(rodMaterial);
        ItemMeta meta = rod.getItemMeta();
        if (meta == null) {
            player.sendMessage(ChatColor.RED + "Could not create the Mob Catcher rod.");
            return true;
        }

        meta.setDisplayName(ChatColor.GOLD + "Mob Catcher");
        meta.setLore(List.of(
                ChatColor.GRAY + "Catches dropped items with its hook.",
                ChatColor.GRAY + "Hooks entities to capture and release them."
        ));
        meta.getPersistentDataContainer().set(rodKey, PersistentDataType.BYTE, (byte) 1);
        XEnchantment.matchXEnchantment("LURE").ifPresent(enchantment ->
                meta.addEnchant(enchantment.getEnchant(), 1, true));
        rod.setItemMeta(meta);

        player.getInventory().addItem(rod).values().forEach(item ->
                player.getWorld().dropItemNaturally(player.getLocation(), item));
        player.sendMessage(ChatColor.GREEN + "You received a " + ChatColor.GOLD + "Mob Catcher" + ChatColor.GREEN + " rod.");
        return true;
    }
}