Bryan Dhanraj

Yo I need a mod tht when I press q it swaps to cob Web and place it and return to whatever ik holding and it must has a config menu

Kodari AI
KodariOct 11 at 9:14 pm 2
WebSwap
WebSwap is a Minecraft Fabric mod for version 1.21.11 that adds a quick web-slinging utility. When the player presses the Q key, the mod automatically swaps the currently held item to a cobweb, places it at the player's feet, and then instantly returns to the original item. The mod includes a comprehensive configuration menu accessible via keybind, allowing players to customize the swap key, toggle the feature on/off, adjust placement offset, and configure whether the cobweb is consumed from inventory or spawned infinitely. The config menu provides intuitive sliders and toggles for seamless personalization.
  1. Add the Q-triggered cobweb placement and restore the previously selected hotbar slot.

  2. Add a configurable settings menu and the required library metadata.

  1. Quick-web action is in place; I’m adding a persistent YACL settings page reachable from Mod Menu.

Press Q while aiming at a block to place the first cobweb stack in your hotbar; your previous slot is restored afterward. While Quick Web is enabled, Q won’t also drop your held item.

Open Mods → Quick Web → Configure to toggle the feature; the setting persists. Cobwebs are vanilla items—keep them in your hotbar to use the shortcut. YACL and Mod Menu are included as dependencies.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
11 277
src/client/java/com/kodari/quickweb/QuickWebClient.java
package com.kodari.quickweb;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.item.Items;
import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;

public final class QuickWebClient implements ClientModInitializer {
    private static final KeyBinding QUICK_WEB = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.quickweb.place", 81, KeyBinding.Category.GAMEPLAY)
    );
    @Override
    public void onInitializeClient() {
        QuickWebConfig.load();
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (QUICK_WEB.wasPressed()) {
                if (isEnabled()) {
                    placeCobweb(client);
                }
            }
        });
    }

    public static boolean isEnabled() {
        return QuickWebConfig.get().enabled;
    }

    public static void setEnabled(boolean enabled) {
        QuickWebConfig.get().enabled = enabled;
    }

    public static boolean sharesDropKey(KeyBinding dropKey) {
        return QUICK_WEB.equals(dropKey);
    }

    private static void placeCobweb(MinecraftClient client) {
        if (client.player == null || client.world == null || client.interactionManager == null
                || !(client.crosshairTarget instanceof BlockHitResult hitResult)) {
            return;
        }

        var player = client.player;
        var inventory = player.getInventory();
        int previousSlot = inventory.getSelectedSlot();
        int cobwebSlot = -1;

        for (int slot = 0; slot < 9; slot++) {
            if (inventory.getStack(slot).isOf(Items.COBWEB)) {
                cobwebSlot = slot;
                break;
            }
        }

        if (cobwebSlot < 0) {
            return;
        }

        try {
            inventory.setSelectedSlot(cobwebSlot);
            client.interactionManager.interactBlock(player, Hand.MAIN_HAND, hitResult);
        } finally {
            inventory.setSelectedSlot(previousSlot);
            if (cobwebSlot != previousSlot) {
                player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(previousSlot));
            }
        }
    }
}