DaRk SiDE

MAKE A minecraft mod and the mod be an item that looks like a lasso and make it super easy to craft the lasso can lead any mob and entity like boat and never break

Kodari AI
KodariOct 15 at 12:05 pm 7
UniversalLasso
Adds a craftable lasso item to Minecraft that can capture and lead any mob or entity, including boats, minecarts, and all passive and hostile creatures. The lasso never breaks, offering infinite durability. Crafting is simple with a single recipe using common materials like string and a lead. Players can right-click any entity to attach the lasso and drag it around, or left-click to capture and release entities into their inventory for transport. The mod integrates seamlessly with Fabric API, providing a lightweight and intuitive tool for entity management and collection.
  • Register a durable, unbreakable lasso item and add it to the creative tools tab.

  • Make entity right-click latch/release a target, with a server-side tether that pulls any entity—including boats—toward its holder.

  • Add an easy survival recipe, item assets, and Fabric 26.3 project metadata.

Added the Lasso mod. Craft a lasso with 1 string + 1 stick in any crafting grid. Right-click a mob or entity—including a boat—to pull it toward you; right-click the same target again to release it. Right-click another target to switch the tether. The lasso has no durability, so it never breaks.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
10 199
src/main/java/com/kodari/lasso/LassoMod.java
package com.kodari.lasso;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.creativetab.v1.CreativeModeTabEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.player.UseEntityCallback;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.CreativeModeTab;

public class LassoMod implements ModInitializer {
	private static final Map<UUID, UUID> TETHERS = new HashMap<>();

	@Override
	public void onInitialize() {
		ModItems.initialize();

		ResourceKey<CreativeModeTab> toolsTab = ResourceKey.create(
				Registries.CREATIVE_MODE_TAB,
				Identifier.fromNamespaceAndPath("minecraft", "tools_and_utilities")
		);
		CreativeModeTabEvents.modifyOutputEvent(toolsTab).register(output -> output.prepend(ModItems.LASSO));

		UseEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> {
			if (player.getItemInHand(hand).getItem() != ModItems.LASSO) {
				return InteractionResult.PASS;
			}

			if (level.isClientSide()) {
				return InteractionResult.SUCCESS;
			}

			UUID playerId = player.getUUID();
			UUID targetId = entity.getUUID();
			if (targetId.equals(TETHERS.get(playerId))) {
				TETHERS.remove(playerId);
				player.sendSystemMessage(Component.literal("Lasso released."));
			} else {
				TETHERS.put(playerId, targetId);
				player.sendSystemMessage(Component.literal("Lasso attached. Right-click the target again to release."));
			}
			return InteractionResult.SUCCESS;
		});

		ServerTickEvents.END_SERVER_TICK.register(server -> TETHERS.entrySet().removeIf(entry -> {
			ServerPlayer holder = server.getPlayerList().getPlayer(entry.getKey());
			if (holder == null || holder.isRemoved()) {
				return true;
			}

			Entity target = holder.level().getEntity(entry.getValue());
			if (target == null || target.isRemoved() || target == holder) {
				return true;
			}

			double distanceSquared = target.distanceToSqr(holder);
			if (distanceSquared > 9.0) {
				double distance = Math.sqrt(distanceSquared);
				double step = Math.min(0.25, distance - 3.0);
				double dx = holder.getX() - target.getX();
				double dy = holder.getY() - target.getY();
				double dz = holder.getZ() - target.getZ();
				target.teleportTo(
						target.getX() + dx / distance * step,
						target.getY() + dy / distance * step,
						target.getZ() + dz / distance * step
				);
			}
			return false;
		}));
	}
}