📄
pasted-code-1791788984534.txt
txt
215 lines
▶
# MASTER PROMPT — LgdAutoMinerFood Fabric Mod
You are an expert Minecraft Java Edition Fabric mod developer. Create a complete, functional, client-side Minecraft mod named **LgdAutoMinerFood**, developed by **Khuzaima Awan — LGD Studio**.
## 1. Project Configuration
* Minecraft Java Edition: 26.2
* Mod loader: Fabric
* Mod ID: `lgdautominerfood`
* Mod name: `LgdAutoMinerFood`
* Main package: `com.lgdstudio.lgdautominerfood`
* Java version: Use the version officially required by Minecraft 26.2.
* Build tool: Gradle with a compatible Fabric Loom version.
* Output JAR: `LgdAutoMinerFood.jar`
* Client-side functionality only.
* Do not require a server-side mod or plugin.
Generate a complete project with all source files, metadata, dependencies, and build instructions. Do not provide pseudocode or incomplete implementations.
## 2. Main Purpose
This mod monitors the player's hunger bar while the player is using an existing AutoMiner system.
Minecraft displays 10 drumstick icons, equivalent to 20 hunger points.
**The trigger threshold is exactly 8/20 hunger points, meaning only 4 filled drumsticks remain.**
When hunger reaches 8/20 or lower, run the following workflow:
1. Send `#stop` through the player's normal chat.
2. Wait for the stop command to be sent.
3. Execute the client-side `/eat` command provided by the separate `LgdAutoEat` mod.
4. Wait until the player's actual hunger level reaches 20/20.
5. Once hunger is full, send `#mine minecraft:ancient_debris` through normal chat.
6. Resume monitoring hunger automatically.
7. Repeat the workflow whenever hunger again reaches 8/20 or lower.
## 3. Exact Command Handling
### Stop AutoMiner
Send this exact chat message:
`#stop`
It must be sent as a normal player chat message to the server.
### Start Auto-Eating
Execute:
`/eat`
Important: `/eat` belongs to the separate `LgdAutoEat` mod. Detect whether that mod is installed and available.
Because `/eat` is a client-side command, invoke its registered client command through the supported client command mechanism. Do not send `/eat` as a server chat message.
If the `LgdAutoEat` mod is missing or the command cannot be invoked, stop the workflow safely and display one clear error message. Never assume that eating has started.
### Resume AutoMiner
After hunger has actually reached 20/20, send this exact chat message:
`#mine minecraft:ancient_debris`
Send it only once per completed eating cycle. Do not send it while hunger is still below 20/20.
## 4. State Machine
Implement a robust, non-blocking state machine with these states:
* `MONITORING`
* `STOPPING_MINER`
* `STARTING_EAT`
* `WAITING_FOR_FULL_HUNGER`
* `RESUMING_MINER`
* `COOLDOWN`
* `ERROR`
Use client tick callbacks and the correct APIs available for Minecraft 26.2.
Workflow:
`MONITORING`
→ Hunger reaches 8/20 or lower
→ `STOPPING_MINER`
→ Send `#stop` once
→ `STARTING_EAT`
→ Invoke the registered `/eat` client command
→ `WAITING_FOR_FULL_HUNGER`
→ Wait for actual hunger to reach 20/20
→ `RESUMING_MINER`
→ Send `#mine minecraft:ancient_debris` once
→ `COOLDOWN`
→ Return to `MONITORING`
Do not block the main game thread or introduce artificial delays that freeze gameplay.
## 5. Hunger Monitoring Rules
* Read the player's actual hunger level using the correct Minecraft client APIs.
* Trigger at `foodLevel <= 8`.
* Do not confuse 4 hunger points with 4 filled drumsticks.
* Hunger must reach `20/20` before mining resumes.
* Use a one-shot trigger for each cycle.
* Do not restart the eating process while it is already active.
* Do not repeatedly send `#stop`, `/eat`, or `#mine` during the same cycle.
* Add a short configurable cooldown after a completed cycle.
* Monitor hunger again after the cooldown.
## 6. Safety and Recovery
Handle these conditions safely:
* Player disconnects.
* Player dies or respawns.
* World unloads or changes.
* Player changes dimension.
* Hunger does not increase.
* Food runs out.
* The `/eat` command is unavailable.
* Server rejects or ignores a command.
* The player is already at full hunger.
* Chat is unavailable.
If the player has no food or hunger does not recover within a configurable timeout, enter `ERROR` and display a single useful client-side message. Never spam chat or resume mining without full hunger.
Reset stale state after disconnects and world changes. Do not keep references to unloaded player instances.
## 7. Configuration
Create a configuration file with these settings:
* `enabled`: true by default.
* `hungerThreshold`: 8.
* `fullHungerTarget`: 20.
* `stopCommand`: `#stop`.
* `eatCommand`: `/eat`.
* `resumeCommand`: `#mine minecraft:ancient_debris`.
* `cooldownSeconds`: configurable.
* `eatingTimeoutSeconds`: configurable.
* `debugLogging`: false by default.
Validate configuration values and prevent invalid hunger thresholds.
## 8. User Commands
Register these client-side commands:
* `/lgdfood on` — Enable monitoring.
* `/lgdfood off` — Disable monitoring.
* `/lgdfood status` — Show current state, hunger, and whether monitoring is enabled.
* `/lgdfood reload` — Reload configuration if supported.
Commands must provide clear client-side feedback without unnecessary chat spam.
## 9. Compatibility
* Integrate with `LgdAutoEat` without creating a hard dependency on inaccessible implementation details.
* Use public APIs or a documented integration interface where possible.
* Detect the presence of the `lgdautoeat` mod.
* Use normal player chat for `#stop` and `#mine minecraft:ancient_debris`.
* Respect server-side command processing and anti-cheat.
* Never fabricate hunger values or assume that a chat command succeeded.
* Avoid mixins unless absolutely necessary.
## 10. Build and Error Verification
Before delivering:
1. Verify the Minecraft 26.2 Fabric API and Loom versions.
2. Use compatible mappings and Java.
3. Check every import, package, entrypoint, and resource path.
4. Ensure `fabric.mod.json` is valid.
5. Compile the project using Gradle.
6. Fix every compilation error.
7. Verify client initialization and command registration.
8. Remove obsolete API calls.
9. Confirm that each state transition happens only once.
10. Do not claim a successful build or runtime test unless it actually passed.
## 11. Deliverables
Provide:
* Complete Gradle project.
* `settings.gradle`
* `build.gradle`
* `gradle.properties`
* `fabric.mod.json`
* Main client initializer.
* Hunger-monitoring controller.
* State-machine implementation.
* Configuration management.
* Client command registration.
* Logging and error handling.
* README with exact setup and build steps.
* Compiled `LgdAutoMinerFood.jar`, if the build environment supports it.
Developer credit: **Khuzaima Awan — LGD Studio**
### Final Acceptance Test
The mod must follow this exact sequence:
`Hunger <= 8/20`
→ Send `#stop`
→ Invoke client-side `/eat`
→ Wait until hunger is `20/20`
→ Send `#mine minecraft:ancient_debris`
→ Resume monitoring
→ Repeat.
No duplicate commands, no premature mining restart, no main-thread blocking, and no fabricated successful results.
Set up the Fabric 26.2 client-only project and metadata.
Implement validated configuration and the non-blocking hunger state machine.
Register client commands and safely invoke the optional
/eatclient command.Add the requested README; report honestly whether a jar was built.
Created the client-only Fabric 26.2 project with the hunger state machine, validated properties configuration, /lgdfood commands, metadata, Gradle files, and README.
The controller sends #stop once, invokes /eat through Fabric’s client-command dispatcher, and sends the resume message only after actual hunger reaches 20/20. Missing /eat or a hunger timeout produces one local error and prevents resuming. Server acceptance of #stop and #mine cannot be confirmed client-side.
No compiled JAR was generated here. The README includes Kodari’s project compile and download steps.
package com.lgdstudio.lgdautominerfood;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
public final class LgdAutoMinerFoodClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
AutoMinerFoodController controller = new AutoMinerFoodController(FoodConfig.load());
ClientTickEvents.END_CLIENT_TICK.register(controller::tick);
LgdFoodCommands.register(controller);
}
}