m
📄
pasted-code-1776584011296.txt
txt
161 lines
▶
You are an expert Minecraft mod developer.
Create a complete, production-ready Minecraft mod for Minecraft version 1.21.4.
MOD NAME: CombatPlus Display (CPD)
MOD TYPE:
Client-side combat HUD enhancement mod.
PLATFORM:
Use Forge. If Forge is not stable for 1.21.4, automatically switch to Fabric.
==================================================
CORE FEATURES
==================================================
1. DAMAGE INDICATOR SYSTEM:
- When the player damages any entity:
- Display floating damage numbers above the entity.
- Animation:
- Smooth upward movement
- Fade-out effect
- Critical hits:
- Larger bold text
- Different color (red/gold)
- Glow effect (optional)
--------------------------------------------------
2. COMBO SYSTEM:
- Track consecutive hits within a 2-second window.
- Display combo counter on HUD:
- Example: "Combo x3", "Combo x8"
- Reset combo if timeout exceeded.
- Add scale animation when combo increases.
--------------------------------------------------
3. CRITICAL HIT EFFECTS:
- Detect Minecraft critical hits.
- Add:
- Subtle screen shake
- Particle burst
- Center text: "CRITICAL!"
--------------------------------------------------
4. DPS TRACKER:
- Track damage dealt in last 5 seconds.
- Show:
- "DPS: XX.X"
- Update in real-time using rolling calculation.
--------------------------------------------------
5. DRAGGABLE HUD SYSTEM (FEATHER STYLE - VERY IMPORTANT):
Implement full HUD EDIT MODE:
- Toggle using keybind (Right Shift)
- When enabled:
- All HUD elements become draggable using mouse
- Show visible bounding boxes
- Highlight selected element
- Allow repositioning:
- Damage indicator anchor
- Combo counter
- DPS meter
- Save positions in config file (JSON or TOML)
- Load positions on game start
--------------------------------------------------
6. CUSTOMIZATION INVENTORY GUI:
Create an in-game settings screen:
Options:
- Toggle:
- Damage numbers
- Combo system
- DPS counter
- Change:
- Text size
- Colors
- HUD positions (manual input optional)
- Enable/disable:
- Particles
- Screen shake
- Reset to default button
All settings must persist via config.
--------------------------------------------------
7. PERFORMANCE OPTIMIZATION:
- All rendering must be client-side only
- Use efficient event listeners
- Avoid unnecessary tick updates
- Ensure no FPS drop during heavy combat
--------------------------------------------------
TECHNICAL REQUIREMENTS:
- Clean modular architecture
- Proper package structure
- Separate:
- Client logic
- Rendering logic
- Game logic
- Use:
- Attack event listeners
- Render overlay events
- Register keybindings properly
- Compatible with Minecraft 1.21.4 rendering system
--------------------------------------------------
FILES TO GENERATE:
- Main mod class
- Client initializer
- Event handler classes
- HUD renderer class
- Drag & INVENTORY GUI system
- Config manager
- Keybind handler
- Combo system utility
- DPS calculator utility
--------------------------------------------------
OPTIONAL FEATURES (IF POSSIBLE):
- Smooth animations (scale + fade)
- Sound effects:
- Combo increase
- Critical hit
- Modular design for future expansion
--------------------------------------------------
OUTPUT REQUIREMENTS:
- Full working source code
- No placeholders or pseudo code
- Must compile successfully
- Provide:
- Folder structure
- Build instructions (Gradle)
- How to run in dev environment
==================================================
IMPORTANT:
The mod must be fully functional, optimized, and stable in Minecraft 1.21.4.
Do not leave incomplete implementations.
Let me read the necessary documentation before writing any code.
Planning the full architecture before writing a single line:
Config:
HudElementConfig,CpdConfig,CpdConfigManager(Gson JSON)HUD systems:
DamageIndicatorEntry/Manager,ComboTracker,DpsTracker,ScreenShakeEffect,HudRendererScreens:
HudEditScreen(drag),SettingsScreen(toggles/options)Wiring:
CombatEventHandler(AttackEntityCallback),KeybindHandler,CombatPlusDisplayClientAll client-only code lives in
src/client/, world-to-screen uses manual camera vector projection (no matrix dependency issues)
Now I have everything I need. Let me write all files.
What was built — complete file list:
File | Purpose |
|---|---|
build.gradle / settings.gradle / gradle.properties | Fabric Loom 1.9.2, MC 1.21.4, Yarn build setup |
fabric.mod.json / cpd.mixins.json | Mod metadata, split env entrypoints |
CombatPlusDisplay.java | Main initializer (client-only mod, no server logic) |
CombatPlusDisplayClient.java | Wires all systems: config load, keybinds, events, HUD |
config/CpdConfig.java | All settings as plain fields with defaults |
config/HudElementConfig.java | x/y/width/height for each draggable HUD box |
config/CpdConfigManager.java | Gson load/save to config/cpd.json |
hud/DamageIndicatorEntry.java | Per-hit data: world pos, damage, crit, age |
hud/DamageIndicatorManager.java | Pooled list, tick-expires old entries |
hud/ComboTracker.java | 2-second window counter with bounce scale animation |
hud/DpsTracker.java | Rolling 5-second deque summed at render time |
hud/ScreenShakeEffect.java | Amplitude+duration shake offsetting HUD draw positions |
hud/HudRenderer.java | All HudRenderCallback drawing + manual camera-vector world→screen projection |
screen/HudEditScreen.java | Drag-to-reposition screen (game not paused), saves on mouse release |
screen/SettingsScreen.java | Toggle buttons, scale cycle, 3 color themes, reset |
input/KeybindHandler.java | Right Shift → HUD edit, K → settings |
event/CombatEventHandler.java | AttackEntityCallback — crit detection, damage estimate, feeds all systems |
To run in dev: ./gradlew runClient — mod loads automatically. Press K for settings, Right Shift to drag HUD elements. Config persists to config/cpd.json.
The compilation failed with this error:
Compilation failed with 2 error(s):
ERROR in src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java at line 66: cannot find symbol
&& !player.isRiding();
^
symbol: method isRiding()
location: variable player of type PlayerEntity
ERROR in src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java at line 66: cannot find symbol
&& !player.isRiding();
^
symbol: method isRiding()
location: variable player of type PlayerEntity
=== COMPILATION ERROR ANALYSIS ===
MISSING METHODS:
- isRiding()
ACTION: Check method names and signatures
FILES TO INVESTIGATE:
- src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java
- src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java
Please fix this error by creating a new artifact with the corrected code.
The compilation failed with this error:
Compilation failed with 2 error(s):
ERROR in src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java at line 66: cannot find symbol
&& !player.isRiding();
^
symbol: method isRiding()
location: variable player of type PlayerEntity
ERROR in src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java at line 66: cannot find symbol
&& !player.isRiding();
^
symbol: method isRiding()
location: variable player of type PlayerEntity
=== COMPILATION ERROR ANALYSIS ===
MISSING METHODS:
- isRiding()
ACTION: Check method names and signatures
FILES TO INVESTIGATE:
- src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java
- src/main/java/client/java/com/example/cpd/event/CombatEventHandler.java
Please fix this error by creating a new artifact with the corrected code.
package com.example.cpd;
import com.example.cpd.config.CpdConfigManager;
import com.example.cpd.event.CombatEventHandler;
import com.example.cpd.hud.ComboTracker;
import com.example.cpd.hud.HudRenderer;
import com.example.cpd.input.KeybindHandler;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
public class CombatPlusDisplayClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
CpdConfigManager.load();
KeybindHandler.register();
CombatEventHandler.register();
HudRenderCallback.EVENT.register(HudRenderer::render);
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player != null) {
ComboTracker.tick();
}
});
}
}