Mufid Khan
📎 1 file 16,032 chars
📄
pasted-code-1792412492351.txt
txt 499 lines
▶
# MASTER PROMPT — AWANFLIP AI AUTO-CF MOD

## 1. PROJECT OVERVIEW

Build a complete, standalone Minecraft client-side Fabric mod named **AwanFlip** from scratch.

Do not use, upload, decompile, depend on, or copy any existing AutoCF or CatFlip mod. Create the complete project independently.

### Target Environment
- Minecraft Java Edition 1.21.11
- Fabric Loader
- Compatible Fabric API
- Java 21, subject to the target environment's actual requirements
- Client-side mod
- Gradle build system
- Gemini API for AI pattern analysis
- Windows-compatible development and installation

### Primary Goal

AwanFlip must automatically create CoinFlip games, detect confirmed results from Minecraft chat, record every result, track user-defined winning patterns, discover candidate patterns through statistical analysis, and manage betting risk.

The mod must not depend on access to the server's internal source code or database.

## 2. COMMAND INTEGRATION

The server's existing CF creation command is:

`/cf create `

Example:

`/cf create 1000`

Requirements:
- Send the command through Minecraft's normal client command/chat mechanism.
- Do not create a separate server plugin.
- Do not assume a command succeeded merely because it was sent.
- Wait for a recognizable server confirmation.
- Handle command rejection, cooldowns, timeouts, and unresolved games.
- Never submit a second creation command while a previous CF is unresolved.
- Do not repeatedly retry an ambiguous command that might already have succeeded.
- Allow the starting amount to be configured.

The mod must work only with the actual command syntax and behavior supported by the connected server.

## 3. KEYBINDS

Register configurable keybinds using Fabric's supported client input APIs.

| Key | Function |
|---|---|
| J | Start/Pause AutoCF |
| K | Emergency Stop |
| , | Settings GUI |
| H | Statistics GUI |

Requirements:
- J toggles between RUNNING and PAUSED.
- K immediately stops further automated actions.
- Emergency Stop cancels pending actions and requires a deliberate restart.
- Comma opens the configuration screen.
- H opens statistics.
- Show the current automation state.
- Avoid duplicate key registration.
- Ensure keybinds do not repeatedly trigger while a key is held.
- Make the keybinds configurable.

## 4. CONFIGURATION FILE

Automatically create:

`.minecraft/config/awanflip.json`

Use the following default structure:

{
  "apiProvider": "gemini",
  "apiKey": "",
  "minecraftUsername": "",
  "startingCF": 1000,
  "betPercentage": 25,
  "cooldownSeconds": 3,
  "maxBetAmount": 5000,
  "maxLossAmount": 5000,
  "maxConsecutiveLosses": 5,
  "maxDailyLoss": 10000,
  "minimumBalance": 1000,
  "autoApplyAIChanges": false,
  "requirePatternValidation": true,
  "winningPoints": [
    {
      "id": "three_losses",
      "name": "Three Consecutive Losses",
      "pattern": ["L", "L", "L"],
      "enabled": true,
      "source": "user"
    },
    {
      "id": "alternating_results",
      "name": "Alternating Loss-Win",
      "pattern": ["L", "W", "L", "W", "L"],
      "enabled": true,
      "source": "user"
    },
    {
      "id": "four_losses",
      "name": "Four Consecutive Losses",
      "pattern": ["L", "L", "L", "L"],
      "enabled": true,
      "source": "user"
    }
  ]
}

These are initial user-defined hypotheses, not verified guarantees of future wins.

Configuration requirements:
- Create the file on first launch.
- Never overwrite a valid existing configuration on startup.
- Validate fields and recover gracefully from malformed JSON.
- Preserve valid settings when possible.
- Write changes atomically.
- Support manual editing and GUI-based editing.
- Provide Reload Config and Save Config actions.
- Never print API keys to Minecraft chat or logs.
- Keep non-AI functionality operational if the API key is absent.
- Do not require recompilation to change the API key.

The API key will be entered by the user into the configuration file.

## 5. MINECRAFT CHAT RESULT PARSER

Only process actual Minecraft chat messages that match the result summary format.

Example:

GAME SUMMARY
LOSER
Amount Bet: $1,000
Winner: clo0p3rs
Loser: MinisterXD

The status line may be WINNER or LOSER. Do not assume it is always LOSER.

Extract:
- Summary identifier, when available.
- Status text.
- Amount Bet.
- Winner username.
- Loser username.
- Timestamp.
- Original parsed result sequence number.

Requirements:
- Parse Minecraft text components rather than screenshots.
- Handle formatting codes and component-based messages.
- Normalize whitespace safely.
- Support currency numbers with thousands separators.
- Do not mistake unrelated messages for results.
- Do not count the same result twice.
- Do not convert missing data into a guessed result.
- Do not infer a player's outcome from the status line alone if the winner and loser fields are available.
- Compare Winner and Loser against the configured Minecraft username.
- If the username matches Winner, record W.
- If the username matches Loser, record L.
- If the username cannot be identified, mark the result UNKNOWN and do not include it in the win/loss pattern sequence.
- Record parse failures in sanitized diagnostic logs.
- Make the parser configurable if the server's actual format differs.

The result history must remain available after the game closes or Minecraft restarts.

## 6. RESULT HISTORY

Store records locally, for example in:

`.minecraft/config/awanflip/history.jsonl`

Each confirmed result should include:
- Unique event identifier or duplicate-detection fingerprint.
- Timestamp.
- Bet amount.
- Winner username.
- Loser username.
- Player outcome: W, L, or UNKNOWN.
- Relevant pattern matches.
- Balance before and after the CF, only if independently verified.
- Source and validation status.

Requirements:
- Never modify past results to fit an AI prediction.
- Use append-only records where practical.
- Detect duplicate summaries.
- Recover gracefully from a partially written final record.
- Keep backups when migrating the history format.
- Provide export and clear-history controls, with confirmation before deletion.

## 7. USER-DEFINED WINNING POINTS

Track the following initial patterns independently.

### Pattern A — Three Consecutive Losses

L → L → L

After the third consecutive loss, the next CF is a candidate winning point.

### Pattern B — Alternating Results

L → W → L → W → L

After this exact sequence, the next CF is a candidate winning point.

### Pattern C — Four Consecutive Losses

L → L → L → L

After the fourth consecutive loss, the next CF is a candidate winning point.

Requirements:
- Track sequences in chronological order.
- Use only confirmed W/L outcomes.
- Never count UNKNOWN results as wins or losses.
- Avoid duplicate CF creation if multiple patterns trigger together.
- Record which patterns triggered each decision.
- Make pattern matching deterministic and unit-testable.
- Reset or update the sequence according to explicitly defined rules.
- Do not assume that a candidate winning point guarantees the next CF will win.

### Bet Calculation

At an enabled candidate point:

`bet = floor(verifiedBalance × betPercentage / 100)`

Default bet percentage: 25%.

Final bet must not exceed:
- Verified available balance.
- Configured maximum bet.
- Any applicable minimum or maximum supported by the server.

If balance cannot be verified, do not automatically place a bet based on a guess.

## 8. GEMINI API INTEGRATION

Use Google Gemini API as the initial AI provider.

Use official, current documentation to select a supported model, API endpoint, request schema, and response format. Never hardcode an assumed model name or unsupported endpoint.

The API key must be loaded from:

`.minecraft/config/awanflip.json`

Requirements:
- Provide an API connection test.
- Handle invalid keys, rate limits, timeouts, network failures, and malformed responses.
- Run API requests asynchronously.
- Never block Minecraft's render or client thread.
- Limit concurrency and prevent duplicate requests.
- Use exponential backoff where appropriate.
- Do not send a request after Emergency Stop if it could trigger an automated action.
- Validate every response before applying it.
- Never let an AI response directly execute a Minecraft command.
- Enforce all risk limits locally.
- Do not include unrelated chat messages or credentials in AI requests.
- Never send the user's API key to another AI service.
- Keep the core mod functional without AI connectivity.

Perform deterministic statistics locally. Use Gemini primarily to propose, explain, and prioritize candidate patterns.

## 9. AI PATTERN DISCOVERY

The AI must investigate patterns beyond the three initially supplied.

For example, it may evaluate sequences such as:

L → W → W → L → L

This is only an example of a candidate, not a known winning pattern.

### Discovery Pipeline

1. Collect confirmed results.
2. Build chronological W/L sequences.
3. Generate candidate sequences of configurable lengths.
4. Calculate how often each sequence occurs.
5. Calculate the next-CF win rate after each occurrence.
6. Compare the observed rate against the baseline win rate.
7. Calculate sample size and confidence intervals.
8. Account for overlapping sequences and repeated testing.
9. Reserve later observations for out-of-sample validation.
10. Report results with clear statistical limitations.
11. Track the performance of each pattern as new results arrive.
12. Reassess previously accepted patterns periodically.

### Avoid False Discoveries

- Do not treat a few wins as evidence of a predictive advantage.
- Do not select only the most successful sequences without accounting for the number of patterns tested.
- Do not confuse historical association with causation.
- Do not claim certainty about a future win.
- If results are consistent with independent random outcomes, report that no reliable predictive edge has been demonstrated.
- If the dataset is too small, report INSUFFICIENT DATA.
- If the data format changes, pause pattern analysis until parsing is reliable.

The AI must be able to conclude that no useful pattern has been found.

## 10. AUTOMATIC PATTERN CORRECTION

AwanFlip must evaluate both user-defined and AI-discovered patterns.

For each pattern, track:
- Pattern identifier.
- Current version.
- Origin: USER or AI.
- Number of occurrences.
- Wins and losses after the pattern.
- Observed win rate.
- Baseline win rate.
- Confidence interval.
- Out-of-sample performance.
- Last evaluation timestamp.
- Current status: UNVERIFIED, CANDIDATE, VALIDATED, UNDERPERFORMING, DISABLED.

### Correction Rules

If a user-defined pattern performs poorly:
- Mark it UNDERPERFORMING or UNVERIFIED.
- Explain the evidence.
- Suggest a replacement only when supported by sufficient data.
- Preserve the original pattern.
- Store revisions as new versions.
- Provide Undo and Restore actions.

If an AI-discovered pattern performs poorly:
- Reduce its priority or disable it.
- Do not keep betting merely because it once performed well.
- Reevaluate it using new observations.

If a new pattern appears promising:
- Add it as a candidate.
- Validate it on unseen data.
- Do not immediately use it for automated betting.
- Promote it only if predefined statistical and risk criteria are satisfied.

### Automatic Changes

Default setting:

`autoApplyAIChanges = false`

When false, show suggested changes and request user confirmation.

When true, allow automatic status changes only if:
- Minimum evidence requirements are met.
- Validation criteria are satisfied.
- Risk limits are unchanged.
- The modification is versioned and reversible.
- The change cannot increase the configured risk limits.

Never silently erase the user's original rules.

## 11. RISK MANAGEMENT

Implement the following configurable controls:
- Maximum bet.
- Maximum loss per session.
- Maximum daily loss.
- Maximum consecutive losses.
- Minimum balance.
- Cooldown.
- Manual pause.
- Emergency Stop.
- Session reset with confirmation.

Requirements:
- Never automatically double a bet after a loss.
- Never increase the bet to chase previous losses.
- Never override Emergency Stop through an API response.
- Stop when a risk limit is reached.
- Clearly display the reason for a stop.
- Reset daily statistics according to a documented timezone setting.
- Do not claim that a stop-loss can recover past losses.

## 12. SETTINGS GUI

Build a clean Minecraft-compatible configuration screen with:

- API provider.
- API key field with masked display where practical.
- Test API button.
- Starting CF amount.
- Bet percentage.
- Maximum bet.
- Maximum loss.
- Maximum consecutive losses.
- Minimum balance.
- Cooldown.
- Winning-point list.
- Add Pattern.
- Edit Pattern.
- Enable/Disable Pattern.
- Restore Default Pattern.
- AI auto-apply toggle.
- Reload Config.
- Save Config.
- Export History.

Display API connection state and sanitized error messages.

## 13. STATISTICS GUI

Show:
- Total confirmed CFs.
- Wins and losses.
- Unknown or unparsed results.
- Current loss streak.
- Longest loss streak.
- Total amount wagered.
- Net result, only if reliable balance changes can be verified.
- Pattern-by-pattern occurrences and observed win rates.
- AI candidate patterns and validation status.
- Last 50 confirmed results.
- Current automation state.
- Last result and last triggered pattern.
- Reason for any automatic pause.

Never display a guessed balance as verified.

## 14. MOD ARCHITECTURE

Use clean, independent, testable components, for example:

- AwanFlipClient
- ConfigManager
- KeybindManager
- ChatResultParser
- ResultHistory
- PatternEngine
- PatternDiscoveryEngine
- PatternValidator
- AIAnalysisService
- RiskManager
- CFCommandController
- SettingsScreen
- StatisticsScreen

Use APIs compatible with the actual target environment. Verify Minecraft 1.21.11 and Fabric dependencies before selecting event hooks.

Do not invent nonexistent Fabric methods or rely on obsolete mappings.

## 15. TESTING REQUIREMENTS

Write and execute automated tests for:

1. Three consecutive losses.
2. Alternating L-W-L-W-L.
3. Four consecutive losses.
4. Multiple patterns triggering simultaneously.
5. Duplicate chat summaries.
6. Missing winner or loser.
7. Username matching.
8. Currency parsing with commas.
9. Invalid API key.
10. Network timeout.
11. Malformed AI response.
12. Insufficient balance.
13. Invalid configuration.
14. Corrupted history recovery.
15. Emergency Stop during a pending action.
16. Rejected CF creation command.
17. Repeated or overlapping sequences.
18. Patterns with insufficient samples.
19. Patterns that fail out-of-sample validation.
20. Automatic pattern rollback.

Build the project and fix actual compilation errors. Do not claim the project works until the build and relevant tests have actually run.

## 16. FINAL DELIVERABLES

Provide:

1. Complete Java source code.
2. Complete Gradle project.
3. Fabric metadata.
4. Gradle wrapper.
5. Unit tests.
6. Build instructions.
7. Installation instructions.
8. Sample `awanflip.json`.
9. Documentation for Gemini API setup.
10. A compiled and tested AwanFlip JAR.

The finished mod must be standalone and must not require CatFlip or any other existing AutoCF mod.

Prioritize correctness, reliable chat parsing, duplicate prevention, risk enforcement, transparent AI analysis, reversible pattern changes, and recovery from errors.

Do not promise guaranteed wins, error-free software, or predictive ability unsupported by validated data.
Kodari AI
KodariOct 19 at 12:38 pm 9
AwanFlipAutoCF
Creates a standalone Minecraft Fabric client mod for 1.21.11 that automates CoinFlip games via the /cf create command. It parses chat result summaries, tracks W/L outcomes, manages user-defined and AI-discovered winning patterns, enforces configurable risk limits, and provides settings and statistics GUIs. Integrates Gemini API for pattern analysis while keeping core functionality operational offline. Includes comprehensive unit tests and Gradle build system.
  1. Create the Fabric 1.21.11 project structure and persistent config/history with deterministic pattern and risk logic.

  2. Add chat result parsing, guarded /cf create automation, and configurable keybinds.

  3. Add asynchronous Gemini analysis and owo-ui settings/statistics screens.

  4. Add assets, sample config, documentation, and focused unit tests.

Created the AwanFlip Fabric 1.21.11 project with Gradle configuration, Fabric metadata, sample config, documentation, JUnit tests, YACL settings, and an owo-ui statistics screen. It includes local result history and deduplication, pattern analysis, guarded /cf create requests, risk limits, and asynchronous Gemini analysis.

Important operating limits: AwanFlip currently parses non-overlay server game/system messages matching the documented GAME SUMMARY format. It recognizes only explicit dollar-formatted balance messages; without a fresh recognized balance, it will not wager. Pattern-triggered betting is blocked by default while requirePatternValidation is enabled. Gemini suggestions are not applied automatically.

The tests are included but were not executed here, so I can’t claim a tested build. The project has Gradle build files, but no Gradle wrapper was generated.

To build and download through Kodari: click Compile in the desktop top bar (phone: ⋮ → Compile Project), click Compile, then Download the successful build bundle. Place the AwanFlip JAR and its bundled YACL/owo-lib JARs in the client’s mods folder.

Mufid Khan

how do i run this mod?

Kodari AI
KodariOct 19 at 12:43 pm 1
  1. Click Compile in the top bar (on phone: ⋮ → Compile Project), then click Compile in the window.

  2. When it succeeds, click Download.

  3. Put the downloaded mod JAR in the mods folder for a Fabric 1.21.11 Minecraft profile, along with Fabric API and any included dependency JARs.

  4. Launch Minecraft using that Fabric profile.

Mufid Khan

whats the command of mod?

Kodari AI
KodariOct 19 at 12:44 pm 1

This mod doesn’t add its own in-game command. Its automation sends /cf create <amount> to the server, which must support that command.

Mufid Khan

wt problem is this?

Kodari AI
KodariOct 19 at 2:53 pm 1

The Gemini API key field is blank (“Click to type…”), and the status says Gemini rejected the key or its permissions. Enter a valid Gemini API key, then click Test Gemini API connection. If it still fails, check that the key is active and allowed to use the Gemini API. Don’t share the key publicly.

Mufid Khan

i am not getting

Kodari AI
KodariOct 19 at 2:56 pm 1

The Gemini API key box is empty. Click “Click to type…” on the Gemini API key row, paste in your key, and save it. If you don’t have one, create one in Google AI Studio. Then click Test Gemini API connection.

If you meant something else by “not getting,” tell me what you expected to happen.

Kodari can make mistakes. Review important code before using.
Files
src
awanflip.example.json
build.gradle
gradle.properties
IMPORTANT.txt
manifest.kod
README.md
settings.gradle
Code
31 2,755
src/client/java/dev/awanflip/client/AwanFlipClient.java
package dev.awanflip.client;

import dev.awanflip.automation.AutomationController;
import dev.awanflip.automation.RiskManager;
import dev.awanflip.config.ConfigManager;
import dev.awanflip.history.ResultHistory;
import dev.awanflip.client.ui.SettingsScreen;
import dev.awanflip.client.ui.StatisticsScreen;
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.message.v1.ClientReceiveMessageEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

import java.nio.file.Path;
import java.time.Instant;

public final class AwanFlipClient implements ClientModInitializer {
    private static ConfigManager configManager;
    private static ResultHistory history;
    private static RiskManager riskManager;
    private static AutomationController automation;
    private static ChatResultParser parser;
    private static KeyBinding toggleKey;
    private static KeyBinding stopKey;
    private static KeyBinding settingsKey;
    private static KeyBinding statisticsKey;

    @Override
    public void onInitializeClient() {
        MinecraftClient client = MinecraftClient.getInstance();
        Path configDirectory = client.runDirectory.toPath().resolve("config");
        configManager = new ConfigManager(configDirectory.resolve("awanflip.json"));
        configManager.load();
        history = new ResultHistory(configDirectory.resolve("awanflip").resolve("history.jsonl"));
        riskManager = new RiskManager();
        automation = new AutomationController(configManager, history, riskManager);
        parser = new ChatResultParser();

        KeyBinding.Category category = KeyBinding.Category.create(Identifier.of("awanflip", "controls"));
        toggleKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.awanflip.toggle", GLFW.GLFW_KEY_J, category));
        stopKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.awanflip.emergency_stop", GLFW.GLFW_KEY_K, category));
        settingsKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.awanflip.settings", GLFW.GLFW_KEY_COMMA, category));
        statisticsKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.awanflip.statistics", GLFW.GLFW_KEY_H, category));

        ClientTickEvents.END_CLIENT_TICK.register(this::onClientTick);
        ClientReceiveMessageEvents.GAME.register((message, overlay) -> {
            if (!overlay) this.acceptMessage(message, MinecraftClient.getInstance());
        });
    }

    private void onClientTick(MinecraftClient client) {
        if (toggleKey.wasPressed()) automation.toggle(client);
        if (stopKey.wasPressed()) automation.emergencyStop();
        if (settingsKey.wasPressed()) client.setScreen(SettingsScreen.createScreen(client.currentScreen));
        if (statisticsKey.wasPressed()) client.setScreen(new StatisticsScreen());
        automation.tick(client, Instant.now());
    }

    private void acceptMessage(Text message, MinecraftClient client) {
        Instant now = Instant.now();
        String plainText = message.getString();
        automation.onChat(plainText, now);
        parser.accept(message, configManager.current().minecraftUsername, now)
                .ifPresent(parsed -> automation.onResult(parsed, client));
    }

    public static ConfigManager configManager() { return configManager; }
    public static ResultHistory history() { return history; }
    public static RiskManager riskManager() { return riskManager; }
    public static AutomationController automation() { return automation; }
}