Create a CLIENT-SIDE Minecraft mod using Fabric for version 1.21.11.
Use latest Fabric API and Yarn mappings.
MOD NAME: TNT Combo Assist (Stable)
---------------------------------- CORE RULE: NEVER CRASH ----------------------------------
- NEVER access Minecraft client/player/world if null
- Only run logic when:
→ client != null → player != null → world != null
- Wrap all combo logic inside safe checks
- Use try-catch around risky actions
- If anything fails → STOP safely (no crash)
---------------------------------- INITIALIZATION FIX ----------------------------------
- Register all logic ONLY after client join world event
- Do NOT run code during game startup menu
- Use ClientTickEvents.END_CLIENT_TICK safely
---------------------------------- HUD BUTTON SYSTEM (SAFE) ----------------------------------
- Render button using safe HUD render event
- Button label: "TNT"
→ Small "⋮" button next to TNT
Edit Mode: - Enable dragging - Disable combo execution - Save position in config
→ Only update when mouse is pressed → Clamp position inside screen bounds
---------------------------------- INPUT SAFETY ----------------------------------
- Detect clicks safely (no spam)
- Debounce clicks (avoid multiple triggers)
---------------------------------- INVENTORY SYSTEM (SAFE) ---------------------------------- On button press:
→ Loop through slots 0–35 → Check item != null
→ Rail → Bow → TNT Minecart
→ RETURN immediately (no action)
- Move items ONLY if needed:
→ Slot 7 = Rail → Slot 8 = Bow → Slot 9 = TNT Minecart
- Use safe slot swap (no invalid index)
---------------------------------- COMBO SYSTEM (TICK-BASED, SAFE) ---------------------------------- DO NOT execute instantly.
Use a STATE MACHINE with ticks:
State 0 → idle State 1 → place rail State 2 → place TNT minecart State 3 → charge bow State 4 → release arrow State 5 → cooldown
---------------------------------- TIMING (VERY IMPORTANT) ---------------------------------- Use client ticks:
- After rail place → wait 2 ticks
- After TNT place → wait 2 ticks
- Bow charge → 12–16 ticks (~0.6–0.8 sec)
---------------------------------- ACTION EXECUTION (SAFE) ----------------------------------
- Use normal interaction methods:
→ interactionManager.interactBlock() → interactionManager.interactItem()
- NEVER spam packets
- Check result of each action:
→ If FAIL → STOP combo
---------------------------------- MOVEMENT SAFETY ----------------------------------
- DO NOT modify player movement
- DO NOT lock camera
- Player can move freely
---------------------------------- COOLDOWN SYSTEM ----------------------------------
- After combo → 30 ticks cooldown (~1.5 sec)
- Prevent spam crashes
---------------------------------- ANTI-CRASH FAILSAFE ---------------------------------- At ANY step:
IF: → player is null → item missing → interaction fails
THEN: → reset state = 0 → stop combo safely
---------------------------------- CONFIG SYSTEM ---------------------------------- Save: → button X/Y position → edit mode state → button visibility
---------------------------------- COMPATIBILITY ----------------------------------
- Minecraft: 1.21.11
- Loader: Fabric
- Works in:
✔ Singleplayer (NO CRASH) ✔ Private servers
---------------------------------- GOAL ---------------------------------- Create a fully stable TNT combo mod that NEVER crashes, uses safe tick-based execution, and behaves like real player input.