crazygamerz0137

m

📎 1 file 3,847 chars
📄
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.
Kodari AI
KodariApr 19 at 7:41 am 58,227 (v2)
CombatPlusDisplay
A client-side combat HUD enhancement mod for Fabric 1.21.4. Features floating damage numbers with smooth animations, a combo tracker with scale effects, critical hit detection with screen shake and particles, a real-time DPS meter, and a fully draggable HUD system. Includes an in-game settings GUI for toggling and customizing all elements. All positions and settings persist via JSON config.

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, HudRenderer

  • Screens: HudEditScreen (drag), SettingsScreen (toggles/options)

  • Wiring: CombatEventHandler (AttackEntityCallback), KeybindHandler, CombatPlusDisplayClient

  • All 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.

CombatPlusDisplay
A client-side Fabric 1.21.4 combat HUD enhancement mod featuring floating damage numbers with smooth upward fade animations, a combo tracker with scale bounce effects, critical hit detection with screen shake and center-screen "CRITICAL!" text, and a real-time 5-second rolling DPS meter. Includes a fully draggable HUD edit mode (Right Shift) and an in-game settings screen (K) for toggling all features, adjusting text scale, and customizing colors. All positions and settings persist via JSON config.

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.

crazygamerz0137

The compilation failed with this error:

code
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.

crazygamerz0137

The compilation failed with this error:

code
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.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
21 1,024
src/client/java/com/example/cpd/CombatPlusDisplayClient.java
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();
            }
        });
    }
}