Dev Verma
πŸ“Ž 1 file 11,736 chars
πŸ“„
pasted-code-1790250806934.txt
txt 581 lines
β–Ά
Create a **Minecraft Fabric 1.21.11 client-side mod** called **Cobweb Master**.

The mod must have a **fully visible in-game GUI/HUD**, a reliable ON/OFF system, and a configurable cobweb escape system using a water bucket.

## 1. ALWAYS-VISIBLE IN-GAME STATUS

The player MUST be able to see whether the mod is enabled while playing.

Add a small configurable HUD indicator in the top-left corner:

```text
Cobweb Master: ON
```

or:

```text
Cobweb Master: OFF
```

The HUD must update immediately when the mod is toggled.

Allow the HUD to be:

* Enabled/disabled
* Moved to different screen positions
* Configured for ON/OFF display

Default position:

`Top Left`

---

# 2. IN-GAME CONFIGURATION GUI

The mod MUST have an actual Minecraft GUI that can be opened while playing.

Default keybind:

`Right Shift`

Pressing Right Shift should open:

```text
╔════════════════════════════════╗
β•‘         COBWEB MASTER           β•‘
╠════════════════════════════════╣
β•‘                                β•‘
β•‘ Cobweb Master:       [ ON ]    β•‘
β•‘                                β•‘
β•‘ Cobweb Assist:        [ ON ]   β•‘
β•‘                                β•‘
β•‘ Cobweb Escape:        [ ON ]   β•‘
β•‘                                β•‘
β•‘ Auto Water Escape:    [ ON ]   β•‘
β•‘                                β•‘
β•‘ Restore Water Bucket: [ ON ]   β•‘
β•‘                                β•‘
β•‘ Escape Item:      Water Bucket β•‘
β•‘                                β•‘
β•‘ HUD Status:          [ ON ]    β•‘
β•‘                                β•‘
β•‘        [ SAVE / CLOSE ]        β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•
```

Every option must be clickable.

Changes should take effect immediately.

The GUI must work **inside an actual Minecraft world/server**, not only from the main menu.

---

# 3. MASTER ON/OFF

The most important setting is:

`Cobweb Master: ON/OFF`

When OFF:

* Disable all Cobweb Master functionality.
* Do not automatically place cobwebs.
* Do not automatically use the water bucket.
* Do not automatically switch inventory slots.
* Return to completely normal Minecraft behavior.

When ON:

* Enable the features individually according to their settings.

The state must persist after restarting Minecraft.

Save configuration to:

```text
config/cobweb-master.json
```

---

# 4. COBWEB PLACEMENT ASSIST

Add:

`Cobweb Assist: ON/OFF`

When enabled, assist the player with precise cobweb placement during PvP.

The player must still initiate the placement.

The mod should:

* Detect the player's intended placement.
* Find a valid cobweb placement position.
* Prefer a position around the target player's feet/body.
* Respect normal Minecraft block-placement rules.
* Respect normal reach distance.
* Avoid placing inside solid blocks.
* Avoid placing through walls.
* Avoid placing where Minecraft would normally reject the placement.

Do not generate cobweb items or bypass server permissions.

Do not automatically attack players.

---

# 5. FAST COBWEB ESCAPE

This is a major feature.

Add:

`Cobweb Escape: ON/OFF`

When the player becomes stuck inside a cobweb, detect the situation.

The default escape item is:

`Water Bucket`

Add:

`Auto Water Escape: ON/OFF`

When enabled, the mod should perform the normal Minecraft water-bucket interaction as quickly as reasonably possible.

The intended sequence is:

```text
PLAYER IS IN COBWEB
        ↓
Detect cobweb
        ↓
Find Water Bucket
        ↓
Select Water Bucket
        ↓
Place water using normal Minecraft interaction
        ↓
Water removes/clears the cobweb according to normal Minecraft mechanics
        ↓
Collect the placed water with the bucket
        ↓
Return the bucket to its previous inventory slot
```

The sequence must use the player's actual inventory and actual Minecraft mechanics.

---

# 6. WATER BUCKET RECOVERY

After using the water bucket:

1. Detect when the water can normally be collected.
2. Perform the normal bucket interaction.
3. Collect the water.
4. Ensure the player has the water bucket again.
5. Restore the previously selected hotbar slot if configured.

Add:

`Restore Previous Slot: ON/OFF`

Default:

`ON`

The mod must NOT create an additional water bucket.

It must use the actual bucket owned by the player.

---

# 7. FAST ESCAPE BEHAVIOR

The sequence should be optimized for quick reaction.

Do not add unnecessary delays.

However, do not bypass Minecraft's normal interaction system or send malicious packets.

Use the normal client interaction methods and synchronize actions appropriately with the server.

The mod should wait only when Minecraft actually requires a state update before the next legitimate interaction.

---

# 8. ESCAPE ITEM SETTINGS

Add:

`Escape Item`

Default:

`Water Bucket`

Allow future support for other configurable items.

If the player does not have the selected item, show:

```text
Cobweb Master
Escape item unavailable!
```

Do nothing else.

---

# 9. HOTBAR MANAGEMENT

When an escape is required:

* Search the hotbar first.
* If the configured item exists in the hotbar, use it.
* Remember the player's original slot.
* Temporarily select the escape item.
* Perform the normal interaction.
* Recover the water when appropriate.
* Restore the original slot.

Add:

`Search Entire Inventory: ON/OFF`

If enabled, the mod may locate the water bucket elsewhere in the player's inventory and move/use it through normal inventory mechanics.

Do not duplicate items.

---

# 10. EMERGENCY ESCAPE KEY

Add a configurable key:

`Cobweb Escape`

Default:

`G`

When the player presses G:

* Check whether the player is inside a cobweb.
* Find the configured escape item.
* Perform the configured escape sequence.
* If the player is not inside a cobweb, do nothing.

This should work even if:

`Auto Water Escape = OFF`

The manual escape key should remain available when Cobweb Escape itself is ON.

---

# 11. TARGETING OPTIONS

Add:

```text
Target Range
Crosshair Target Priority
Feet Placement
Body Placement
```

Default:

```text
Target Range: 4.5 blocks
Crosshair Target Priority: ON
Feet Placement: ON
Body Placement: OFF
```

The player should remain in control of targeting.

Do not automatically attack targets.

---

# 12. HUD

The HUD should show:

```text
Cobweb Master: ON
Escape: READY
Water Bucket: βœ“
```

When the player is inside a cobweb:

```text
Cobweb Master: ON
ESCAPE READY
Water Bucket: βœ“
```

If no water bucket exists:

```text
Cobweb Master: ON
ESCAPE UNAVAILABLE
Water Bucket: βœ—
```

Allow HUD visibility to be disabled in settings.

---

# 13. TOGGLE KEY

Add:

`Toggle Cobweb Master`

Default:

`Right Shift`

Pressing it should instantly switch:

```text
Cobweb Master: ON
```

to:

```text
Cobweb Master: OFF
```

and vice versa.

Show a small notification:

```text
Cobweb Master ENABLED
```

or:

```text
Cobweb Master DISABLED
```

The toggle must work while connected to a multiplayer server.

---

# 14. MOD MENU

Add Mod Menu compatibility.

The configuration screen should be accessible from:

* Mod Menu
* Right Shift keybind
* In-game configuration screen

The GUI must NOT only exist in the Mod Menu.

There must be a way to open it directly while playing.

---

# 15. MULTIPLAYER / SERVER COMPATIBILITY

Make the mod **client-side**.

The server should not need to install the mod.

The mod should use normal Minecraft client interactions for:

* Block placement
* Bucket usage
* Water collection
* Inventory switching
* Player interaction

Do not:

* Create items.
* Duplicate items.
* Bypass permissions.
* Bypass protected regions.
* Forge fake inventory states.
* Spoof impossible player actions.
* Attempt to bypass anti-cheat systems.

Different servers may have different anti-cheat or gameplay rules, so the mod must not claim that it can bypass every server's restrictions.

The goal is for the mod to be broadly compatible with normal multiplayer servers while respecting their server-side validation.

---

# 16. PERFORMANCE

Keep the mod lightweight.

Do not scan the entire world every tick.

Cobweb detection should only check the player's relevant position/block state.

Only perform target calculations when Cobweb Assist is enabled and the player is attempting a relevant placement.

The water escape system should activate only when necessary.

---

# 17. CONFIGURATION FILE

Use:

```text
config/cobweb-master.json
```

Example configuration:

```json
{
  "enabled": true,
  "cobwebAssist": true,
  "cobwebEscape": true,
  "autoWaterEscape": true,
  "restorePreviousSlot": true,
  "escapeItem": "minecraft:water_bucket",
  "targetRange": 4.5,
  "crosshairPriority": true,
  "feetPlacement": true,
  "bodyPlacement": false,
  "hudEnabled": true,
  "hudPosition": "TOP_LEFT",
  "notifications": true
}
```

All settings must persist after Minecraft is closed.

---

# 18. MINECRAFT VERSION

Target EXACTLY:

```text
Minecraft: 1.21.11
Loader: Fabric
Mod type: Client-side
```

Before generating the implementation, verify all APIs against **Minecraft 1.21.11**.

Do not blindly use APIs, mappings, mixins, or methods from Minecraft 1.20.x or older 1.21.x versions.

Verify:

* Fabric Loader
* Fabric API
* Yarn mappings
* Java version
* Screen APIs
* Keybind APIs
* Client interaction APIs
* Inventory APIs
* Block-state APIs
* Player APIs
* Mixin targets
* Mod Menu API

---

# 19. COMPLETE PROJECT

Generate the complete Gradle project:

```text
CobwebMaster/
β”œβ”€β”€ build.gradle
β”œβ”€β”€ gradle.properties
β”œβ”€β”€ settings.gradle
β”œβ”€β”€ gradlew
β”œβ”€β”€ gradlew.bat
β”œβ”€β”€ gradle/
└── src/
    └── main/
        β”œβ”€β”€ java/
        β”‚   └── ...
        └── resources/
            β”œβ”€β”€ fabric.mod.json
            β”œβ”€β”€ cobweb-master.mixins.json
            └── assets/
                └── cobwebmaster/
                    β”œβ”€β”€ icon.png
                    └── lang/
                        └── en_us.json
```

Include all required source files.

---

# 20. BUILD TEST

The project MUST compile with:

```bash
./gradlew build
```

The output JAR should be:

```text
build/libs/
```

Before giving the code, verify that:

* The GUI actually opens in-game.
* Right Shift toggles the master setting.
* The HUD displays the current ON/OFF state.
* G activates manual cobweb escape.
* Automatic escape can be disabled.
* Water Bucket is found correctly.
* Water is placed through normal Minecraft interaction.
* The water bucket is recovered normally.
* The original hotbar slot can be restored.
* No items are duplicated.
* No fake items are created.
* Cobweb Assist can be disabled independently.
* Cobweb Escape can be disabled independently.
* The entire mod can be disabled with one master switch.
* Settings persist after restarting Minecraft.
* The project contains no missing imports or nonexistent 1.21.11 APIs.

## MOST IMPORTANT REQUIREMENT

The finished mod must have a **real in-game GUI and HUD**.

The player must be able to join a server, press **Right Shift**, and immediately see and change:

```text
Cobweb Master: ON/OFF
Cobweb Assist: ON/OFF
Cobweb Escape: ON/OFF
Auto Water Escape: ON/OFF
Escape Item: Water Bucket
HUD: ON/OFF
```

The water escape should perform the normal water-bucket placement and collection sequence as quickly as Minecraft/server synchronization legitimately allows.
Kodari AI
KodariSep 24 at 12:01 pm 5
CobwebMaster
A client-side Fabric mod for Minecraft 1.21.11 that provides a comprehensive cobweb management system. Features include an always-visible HUD indicator showing mod status, a fully interactive in-game configuration GUI opened via Right Shift, master ON/OFF toggle, automated cobweb placement assistance during PvP, and a fast water-bucket escape system that automatically detects when the player is stuck in cobwebs, selects the water bucket, places water to clear the cobweb, collects the water back, and restores the previous hotbar slot. Includes configurable targeting options, emergency escape key (G), persistent JSON configuration, Mod Menu compatibility, and full multiplayer server compatibility using only normal Minecraft client interactions.
  1. Set up the Fabric 1.21.11 client project and dependencies, including Mod Menu compatibility.

  2. Implement persistent settings, the in-game settings screen, keybinds, and status HUD.

  3. Implement cobweb escape and a normal-interaction placement assist, with inventory/targeting options.

Created the Cobweb Master Fabric project for Minecraft 1.21.11, with persistent settings, a clickable in-game configuration screen, a movable HUD, Right Shift toggle/settings access, G manual escape, and Mod Menu integration.

The escape flow uses the player’s water bucket and normal client interactions; optional inventory search swaps a bucket through the player’s inventory and can restore the previous slot. Placement assist only adjusts a cobweb use when the player is already interacting with a valid support block at a nearby player, leaving reach and placement checks to Minecraft and the server.

Build and behavior are not verified: I did not run ./gradlew build or test in a Minecraft client/server. The included launcher downloads Gradle if needed, but vanilla cobweb/water behavior and server validation can prevent the requested escape sequence from succeeding in some situations.

Kodari can make mistakes. Review important code before using.
Files
gradle
src
build.gradle
gradle.properties
gradlew
gradlew.bat
manifest.kod
settings.gradle
Code
15 693
src/client/java/com/kodari/cobwebmaster/CobwebMasterClient.java
package com.kodari.cobwebmaster;

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.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.screen.slot.SlotActionType;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class CobwebMasterClient implements ClientModInitializer {
    public static final String MOD_ID = "cobwebmaster";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    public static CobwebConfig config;

    private static KeyBinding toggleAndConfigKey;
    private static KeyBinding escapeKey;
    private static EscapeStage escapeStage = EscapeStage.IDLE;
    private static int escapeTimer;
    private static int originalSlot;
    private static int escapeHotbarSlot;
    private static int swappedInventorySlot = -1;

    private enum EscapeStage {
        IDLE,
        WAITING_FOR_HOTBAR_ITEM,
        PLACE_SENT,
        COLLECT_SENT,
        WAITING_FOR_COLLECTION
    }

    @Override
    public void onInitializeClient() {
        config = CobwebConfig.load();

        KeyBinding.Category category = KeyBinding.Category.create(Identifier.of(MOD_ID, "general"));
        toggleAndConfigKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.cobwebmaster.open_config", GLFW.GLFW_KEY_RIGHT_SHIFT, category));
        escapeKey = KeyBindingHelper.registerKeyBinding(
                new KeyBinding("key.cobwebmaster.escape", GLFW.GLFW_KEY_G, category));

        ClientTickEvents.END_CLIENT_TICK.register(CobwebMasterClient::tick);
        HudElementRegistry.addLast(Identifier.of(MOD_ID, "status"), (context, tickCounter) -> renderHud(context));
    }

    public static Screen createConfigScreen(Screen parent) {
        return new CobwebConfigScreen(parent);
    }

    private static void tick(MinecraftClient client) {
        while (toggleAndConfigKey.wasPressed()) {
            config.enabled = !config.enabled;
            config.save();
            if (config.notifications && client.player != null) {
                client.player.sendMessage(Text.literal("Cobweb Master " + (config.enabled ? "ENABLED" : "DISABLED")), true);
            }
            client.setScreen(new CobwebConfigScreen(client.currentScreen));
        }

        boolean manualRequest = false;
        while (escapeKey.wasPressed()) {
            manualRequest = true;
        }

        if (client.player == null || client.world == null || client.interactionManager == null) {
            resetEscape(client, false);
            return;
        }
        if (!config.enabled || !config.cobwebEscape) {
            resetEscape(client, true);
            return;
        }
        if (client.currentScreen != null) {
            return;
        }

        boolean inCobweb = isInCobweb(client);
        if (escapeStage == EscapeStage.IDLE && inCobweb && (manualRequest || config.autoWaterEscape)) {
            beginEscape(client);
        }

        if (escapeStage != EscapeStage.IDLE) {
            advanceEscape(client);
        }
    }

    private static void beginEscape(MinecraftClient client) {
        if (!"minecraft:water_bucket".equals(config.escapeItem)) {
            notifyUnavailable(client);
            return;
        }

        int foundSlot = findWaterBucket(client);
        if (foundSlot < 0) {
            notifyUnavailable(client);
            return;
        }

        var inventory = client.player.getInventory();
        originalSlot = inventory.getSelectedSlot();
        escapeHotbarSlot = foundSlot < 9 ? foundSlot : originalSlot;
        swappedInventorySlot = -1;
        escapeTimer = 0;

        if (foundSlot < 9) {
            inventory.setSelectedSlot(foundSlot);
            escapeStage = EscapeStage.PLACE_SENT;
        } else {
            swappedInventorySlot = foundSlot;
            client.interactionManager.clickSlot(client.player.currentScreenHandler.syncId, foundSlot,
                    originalSlot, SlotActionType.SWAP, client.player);
            escapeStage = EscapeStage.WAITING_FOR_HOTBAR_ITEM;
        }
    }

    private static void advanceEscape(MinecraftClient client) {
        if (++escapeTimer > 80) {
            resetEscape(client, true);
            return;
        }

        var inventory = client.player.getInventory();
        if (escapeStage == EscapeStage.WAITING_FOR_HOTBAR_ITEM) {
            if (inventory.getStack(escapeHotbarSlot).isOf(Items.WATER_BUCKET)) {
                inventory.setSelectedSlot(escapeHotbarSlot);
                escapeStage = EscapeStage.PLACE_SENT;
            } else {
                return;
            }
        }

        if (escapeStage == EscapeStage.PLACE_SENT) {
            if (!inventory.getStack(escapeHotbarSlot).isOf(Items.WATER_BUCKET)) {
                return;
            }
            client.interactionManager.interactItem(client.player, Hand.MAIN_HAND);
            escapeStage = EscapeStage.COLLECT_SENT;
            return;
        }

        if (escapeStage == EscapeStage.COLLECT_SENT) {
            if (inventory.getStack(escapeHotbarSlot).isOf(Items.WATER_BUCKET)) {
                resetEscape(client, true);
                return;
            }
            if (inventory.getStack(escapeHotbarSlot).isOf(Items.BUCKET)
                    && client.crosshairTarget instanceof BlockHitResult hit
                    && client.world.getBlockState(hit.getBlockPos()).isOf(Blocks.WATER)) {
                client.interactionManager.interactBlock(client.player, Hand.MAIN_HAND, hit);
                escapeStage = EscapeStage.WAITING_FOR_COLLECTION;
            }
            return;
        }

        if (escapeStage == EscapeStage.WAITING_FOR_COLLECTION
                && inventory.getStack(escapeHotbarSlot).isOf(Items.WATER_BUCKET)) {
            resetEscape(client, true);
        }
    }

    private static void resetEscape(MinecraftClient client, boolean restore) {
        if (restore && client.player != null && client.interactionManager != null && escapeStage != EscapeStage.IDLE) {
            if (swappedInventorySlot >= 9 && swappedInventorySlot < 36) {
                client.interactionManager.clickSlot(client.player.currentScreenHandler.syncId, swappedInventorySlot,
                        originalSlot, SlotActionType.SWAP, client.player);
            }
            if (config.restorePreviousSlot) {
                client.player.getInventory().setSelectedSlot(originalSlot);
            }
        }
        escapeStage = EscapeStage.IDLE;
        escapeTimer = 0;
        swappedInventorySlot = -1;
    }

    private static int findWaterBucket(MinecraftClient client) {
        int lastSlot = config.searchEntireInventory ? 35 : 8;
        for (int slot = 0; slot <= lastSlot; slot++) {
            if (client.player.getInventory().getStack(slot).isOf(Items.WATER_BUCKET)) {
                return slot;
            }
        }
        return -1;
    }