dark_sharpness
📎 1 file 9,478 chars
📄
pasted-code-1791366526706.txt
txt 566 lines
▶
# A2Z MASTER PROMPT — Fabric 1.21.11 CF AUTO-BALANCE MOD

You are an expert Minecraft Fabric mod developer.

Create a complete, clean, production-ready **client-side Fabric mod for Minecraft Java Edition 1.21.11**.

## 1. MOD PURPOSE

The mod is a CF (Coin Flip) automation/helper mod.

Its main job is:

1. Run `/bal`.
2. Read the balance response sent by the Minecraft server.
3. Detect/extract the player's available money.
4. Store that amount as `{money}`.
5. Take a configurable CF command/template.
6. Replace `{money}` with the detected balance.
7. Send the resulting command through the normal Minecraft client chat/command system.

Example:

Server response:

`Balance: $25,430`

Detected money:

`25430`

Configured command:

`/cf {money}`

Command actually sent:

`/cf 25430`

DO NOT hard-code the CF command. I will manually add/change the command/template inside the generated project.

---

# 2. PLATFORM

Minecraft:

* Java Edition
* Version: 1.21.11

Mod loader:

* Fabric

The mod must be CLIENT-SIDE.

Use the correct Fabric API and mappings compatible with Minecraft 1.21.11.

Use Java version appropriate for Fabric/Minecraft 1.21.11.

Do not use Forge.
Do not use NeoForge.
Do not create an Android app.
Do not create a standalone launcher.

---

# 3. PROJECT REQUIREMENTS

Generate the complete Gradle Fabric project.

Include all required files:

* `build.gradle`
* `gradle.properties`
* `settings.gradle`
* `gradlew`
* `gradlew.bat`
* `gradle/wrapper/...`
* `src/main/java/...`
* `src/main/resources/fabric.mod.json`
* any required mixins
* configuration files
* README

The project must compile without missing classes or unresolved imports.

Before finishing, verify the project structure and fix compilation errors.

---

# 4. MOD NAME

Use a clean name such as:

`CoinFlipHelper`

Suggested mod ID:

`coinfliphelper`

Make the mod name easy to change later.

---

# 5. CORE WORKFLOW

Implement this exact workflow:

### STEP 1 — Start

When the CF automation is activated, first send:

`/bal`

using the normal Minecraft client command/chat mechanism.

Do NOT attempt to directly access server-side economy data.

The mod must obtain the balance only from the server's response visible to the client.

---

### STEP 2 — WAIT FOR BALANCE RESPONSE

After `/bal` is sent:

* wait for incoming chat/system messages;
* inspect received text;
* search for a balance amount;
* extract the numeric money value;
* support common formats such as:

`Balance: $25000`

`Your balance is $25,000`

`Money: 25000`

`$25,000.50`

The parser should be configurable and easy to modify.

Do not assume that every server uses exactly the same `/bal` message.

---

# 6. MONEY PARSER

Create a dedicated class:

`BalanceParser`

Responsibilities:

* receive server message text;
* remove Minecraft formatting;
* normalize spaces;
* detect currency symbols;
* detect commas;
* detect decimal values;
* extract the balance;
* return a clean numeric/string representation.

Examples:

Input:

`Balance: $25,430`

Output:

`25430`

Input:

`Your balance is $1,250,000`

Output:

`1250000`

Input:

`Money: 5000`

Output:

`5000`

Do not accidentally extract unrelated numbers such as player names, timestamps, ranks, etc.

Prioritize the number nearest to balance-related keywords such as:

* balance
* money
* cash
* wallet
* bal

Make the parser modular so I can modify it later.

---

# 7. {money} PLACEHOLDER

Create a configurable command template.

Example:

`/cf {money}`

When the detected balance is:

`25430`

replace:

`{money}`

with:

`25430`

Final command:

`/cf 25430`

The placeholder must be exactly:

`{money}`

Support case-sensitive exact replacement.

Do not send `{money}` literally to the server.

If `{money}` does not exist in the configured command, simply send the configured command as-is.

---

# 8. COMMAND CONFIGURATION

Create a clearly marked configuration section where I can manually add/edit commands.

For example:

```text
BALANCE_COMMAND = "/bal"

CF_COMMAND = "/cf {money}"
```

OR use a JSON configuration file if that is cleaner.

If using JSON, create something like:

```json
{
  "balanceCommand": "/bal",
  "cfCommand": "/cf {money}",
  "balanceTimeout": 5000
}
```

I must be able to easily change:

* `/bal`
* CF command
* timeout
* parser settings

WITHOUT modifying the core automation logic.

Add comments or README instructions explaining exactly where I should put my command.

---

# 9. ACTIVATION COMMANDS

Add client-side commands:

`/cfmod on`

`/cfmod off`

`/cfmod status`

`/cfmod reload`

Behavior:

### `/cfmod on`

Enable the automation.

### `/cfmod off`

Disable the automation immediately.

### `/cfmod status`

Show whether the mod is:

* ON
* OFF
* WAITING_FOR_BALANCE
* READY
* ERROR

### `/cfmod reload`

Reload configuration without restarting Minecraft.

---

# 10. IMPORTANT SAFETY STATE MACHINE

Do NOT create uncontrolled command spam.

Use states:

```text
IDLE
WAITING_FOR_BALANCE
BALANCE_RECEIVED
EXECUTING
COOLDOWN
ERROR
```

Only one CF automation cycle may run at a time.

Never repeatedly execute `/bal` in a tight loop.

Never repeatedly send the CF command because of duplicate chat messages.

Add configurable delays.

Example:

```text
balanceRequestDelay = 0ms
balanceTimeout = 5000ms
commandDelay = 250ms
cooldown = 1000ms
```

Make these values configurable.

---

# 11. DUPLICATE MESSAGE PROTECTION

The server may send multiple messages.

Prevent the same balance response from triggering the command multiple times.

Once a valid balance has been extracted for the current cycle:

* stop searching for another balance;
* use the first valid result;
* proceed to command generation.

Ignore duplicate messages until the current cycle is complete.

---

# 12. CHAT MESSAGE HANDLING

Handle:

* normal chat
* system messages
* server messages
* formatted messages

Strip Minecraft formatting before parsing.

The parser must not depend on color codes.

For example:

`§aBalance: §f$25,430`

must become:

`Balance: $25,430`

before parsing.

---

# 13. COMMAND EXECUTION

Commands must be sent using the normal client command/chat API.

Do NOT:

* spoof packets;
* bypass permissions;
* bypass server restrictions;
* modify server data;
* exploit an economy plugin;
* fake balance;
* intercept authentication;
* bypass anti-cheat.

The mod only automates actions that the player can normally perform through their Minecraft client.

If the server does not allow `/cf`, the mod must not attempt to bypass that restriction.

---

# 14. ERROR HANDLING

Handle these situations cleanly:

### No balance detected

Show:

`[CF Mod] Balance not detected.`

Do not execute the CF command.

### Timeout

If no balance is detected within the configured timeout:

`[CF Mod] Balance request timed out.`

Return to IDLE.

### Invalid balance

If the detected value is invalid:

`[CF Mod] Invalid balance detected.`

Do not execute the CF command.

### CF command missing

If no CF command is configured:

`[CF Mod] CF command is not configured.`

### Placeholder problem

If configured command contains invalid placeholders, show a useful error.

---

# 15. CHAT FEEDBACK

Use clean client-side messages.

Examples:

When starting:

`[CF Mod] Checking balance...`

After balance detection:

`[CF Mod] Balance detected: $25,430`

Before execution:

`[CF Mod] Executing CF with $25,430`

After sending:

`[CF Mod] CF command sent.`

Errors:

`[CF Mod] Balance not detected.`

`[CF Mod] Timeout.`

Keep messages short and readable.

---

# 16. CONFIG FILE

Prefer:

`config/coinfliphelper.json`

Example:

```json
{
  "enabled": false,
  "balanceCommand": "/bal",
  "cfCommand": "/cf {money}",
  "balanceTimeout": 5000,
  "commandDelay": 250,
  "cooldown": 1000
}
```

The exact implementation can be improved if Fabric's recommended configuration approach requires it.

Do not overwrite the user's manually edited command when reloading.

---

# 17. MODULAR CODE STRUCTURE

Use clean separation.

Suggested structure:

```text
src/main/java/
└── com/
    └── coinfliphelper/
        ├── CoinFlipHelper.java
        ├── command/
        │   └── CFModCommand.java
        ├── config/
        │   └── ModConfig.java
        ├── automation/
        │   └── CFAutomation.java
        ├── parser/
        │   └── BalanceParser.java
        ├── chat/
        │   └── ChatListener.java
        └── util/
            └── MessageUtil.java
```

You may improve the structure if necessary, but keep responsibilities separated.

---

# 18. CONFIGURATION PRIORITY

The manually configured CF command is extremely important.

Clearly mark the section:

```text
===============================
EDIT YOUR CF COMMAND HERE
===============================
```

I should be able to immediately find it.

Example:

```text
CF_COMMAND = "/cf {money}"
```

Do not hide this inside complicated code.

---

# 19. FLEXIBLE COMMAND TEMPLATE

The CF command may c
Kodari AI
KodariOct 7 at 9:59 am 2
CoinFlipHelper
A client-side Fabric mod for Minecraft 1.21.11 that automates the Coin Flip (CF) process. It sends a configurable balance command, parses the server's response to extract the player's money, and uses that value to fill a configurable command template with a {money} placeholder. Features a state machine to prevent spam, configurable timeouts and delays, a robust balance parser that strips formatting and handles various currency formats, and client-side commands to enable, disable, check status, and reload configuration. All settings are stored in a JSON config file for easy editing without code changes.
  1. Create the Fabric 1.21.11 project skeleton and client entrypoint.

  2. Add editable JSON configuration, balance parsing, and a guarded one-cycle automation state machine.

  3. Register client commands and chat/tick callbacks, plus the mod metadata and README.

Created the client-side Fabric 1.21.11 project with balance parsing, editable JSON config, client commands, chat/system-message handling, and a guarded one-cycle automation flow.

Edit the CF command in config/coinfliphelper.json under cfCommand. Use /cfmod on to run one cycle; /cfmod off, /cfmod status, and /cfmod reload control it. The project includes Gradle build files and a README; a Gradle wrapper JAR is not included.

dark_sharpness

/bal ke baad 3 sec wait kre phir /cf {money}command run kre

Kodari AI
KodariOct 7 at 11:16 am 1

Ab /bal bhejne ke baad kam-se-kam 3 seconds rukega, phir balance response milne par /cf {money} bhejega. Agar balance 3 seconds se baad aaye, to response milte hi command chalega. Naye config mein commandDelay default 3000 ms hai; pehle se config file ho to usmein bhi commandDelay ko 3000 set karein.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
README.md
settings.gradle
Code
10 531
src/client/java/com/coinfliphelper/CoinFlipHelperClient.java
package com.coinfliphelper;

import com.coinfliphelper.automation.CFAutomation;
import com.coinfliphelper.command.CFModCommand;
import com.coinfliphelper.config.ModConfig;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Path;

public final class CoinFlipHelperClient implements ClientModInitializer {
    public static final String MOD_ID = "coinfliphelper";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    private static CFAutomation automation;
    private static Path configPath;

    @Override
    public void onInitializeClient() {
        configPath = FabricLoader.getInstance().getConfigDir().resolve("coinfliphelper.json");
        ModConfig config = loadConfig();
        automation = new CFAutomation(config);

        CFModCommand.register(automation, CoinFlipHelperClient::reloadConfig);
        ClientReceiveMessageEvents.CHAT.register((message, signedMessage, sender, params, receptionTimestamp) ->
                automation.onServerMessage(message.getString()));
        ClientReceiveMessageEvents.GAME.register((message, overlay) ->
                automation.onServerMessage(message.getString()));
        ClientTickEvents.END_CLIENT_TICK.register(automation::tick);
    }

    private static void reloadConfig() {
        ModConfig config = loadConfig();
        automation.reloadConfig(config);
    }

    private static ModConfig loadConfig() {
        try {
            return ModConfig.load(configPath);
        } catch (IOException exception) {
            LOGGER.error("Could not load config at {}. Using defaults without replacing the file.", configPath, exception);
            return new ModConfig();
        }
    }

    public static void sendFeedback(String message) {
        MinecraftClient client = MinecraftClient.getInstance();
        if (client.player != null) {
            client.player.sendMessage(net.minecraft.text.Text.literal("[CF Mod] " + message), false);
        }
    }
}