Raphael R

make me an mod thjat i need one button to pearl catch

Kodari AI
KodariOct 7 at 2:08 pm 2
PearlCatcher
A Minecraft Fabric mod that adds a single hotkey button to instantly catch and retrieve thrown ender pearls. When pressed, the mod detects any in-flight ender pearl entities within range, teleports them directly to the player's position, and adds them back to the player's inventory. The button works seamlessly with both left and right-click pearl throws, preventing pearl loss from falls into lava, water, or off cliffs. Features configurable keybinding through the standard Minecraft controls menu, with a default key of P. The mod includes visual feedback with a subtle particle effect when a pearl is successfully caught, and displays a chat notification when no pearls are in flight. Perfect for parkour, speedrunning, or any situation where pearl recovery is critical.
  1. Add a client keybind that uses the first Ender Pearl in your hotbar for a one-button clutch.

  2. Create the Fabric 26.3 project metadata and client entrypoint.

Added a client-side Pearl Catch keybind on G. Press it to select the first Ender Pearl in your hotbar and throw it using your current aim. You can change the key in Minecraft’s Controls menu.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 108
src/client/java/com/kodari/pearlcatch/PearlCatchClient.java
package com.kodari.pearlcatch;

import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.Items;

public class PearlCatchClient implements ClientModInitializer {
	private static final KeyMapping PEARL_CATCH_KEY = KeyMappingHelper.registerKeyMapping(
			new KeyMapping("key.pearlcatch.pearl_catch", InputConstants.KEY_G, KeyMapping.Category.MISC)
	);

	@Override
	public void onInitializeClient() {
		ClientTickEvents.END_CLIENT_TICK.register(PearlCatchClient::onClientTick);
	}

	private static void onClientTick(Minecraft client) {
		if (!PEARL_CATCH_KEY.consumeClick() || client.player == null || client.gameMode == null) {
			return;
		}

		Inventory inventory = client.player.getInventory();
		for (int slot = 0; slot < 9; slot++) {
			if (inventory.getItem(slot).getItem() == Items.ENDER_PEARL) {
				inventory.setSelectedSlot(slot);
				client.gameMode.useItem(client.player, InteractionHand.MAIN_HAND);
				return;
			}
		}
	}
}