pgon1324-cloud

make me a java mod that adds "Parrying" to melee weapons that damages the attacker and knocks them back

Kodari AI
KodariApr 17 at 3:18 pm 12,463 (v2)

I’ll create a combat enhancement mod that adds a parrying mechanic to melee weapons.

CombatParry
A combat enhancement mod that adds a parrying mechanic to melee weapons. Players can parry incoming attacks by timing their defense correctly, reflecting damage back to the attacker and knocking them back. Features configurable parry window timing, damage reflection percentage, and knockback strength. Works with all vanilla melee weapons including swords, axes, and tridents. Enhances combat depth with skill-based defensive mechanics.

Now I’ll create the complete parrying system with configurable timing, damage reflection, and knockback.

Perfect! I’ve created a complete Combat Parry mod with the following features:

Core Mechanics:

  • Right-click with any melee weapon (sword, axe, trident) to activate parry mode

  • 300ms parry window (configurable)

  • If attacked during the window, the attack is parried

  • Damage is reflected back to the attacker (100% by default)

  • Attacker is knocked back (1.5 strength by default)

Configuration (config/combatparry.json):

  • parryWindowMs: Time window to parry (default: 300ms)

  • damageReflectionPercent: How much damage to reflect (default: 100%)

  • knockbackStrength: Knockback force applied (default: 1.5)

  • enableParticles: Show gold dust and sweep particles on successful parry

  • enableSound: Play shield block sound effects

Technical Implementation:

  • Uses Fabric’s Data Attachments API to track parry state

  • Event-based system for damage interception

  • Works with all vanilla melee weapons automatically

  • Multiplayer-compatible with server-side validation

pgon1324-cloud

make the parry have another indicator when its active and show an indicator for a cooldown

Kodari AI
KodariApr 17 at 3:29 pm 13,582 (v2)

I’ll add a visual HUD indicator for active parry and cooldown display, plus a cooldown system.

Perfect! I’ve added a complete visual indicator system with cooldown tracking:

New Features:

  1. Active Parry Indicator - Bright green box with “PARRY!” text appears next to crosshair during the 300ms parry window

  2. Cooldown Bar - Orange filling bar shows cooldown progress with remaining time in seconds

  3. Cooldown System - 2-second cooldown (configurable) prevents parry spam

  4. Network Sync - Server sends parry state to client for accurate HUD display

Configuration (in config/combatparry.json):

  • parryCooldownMs: Cooldown duration (default: 2000ms)

  • showHudIndicators: Toggle HUD display on/off (default: true)

How It Works:

  • Right-click with sword/axe/trident to activate parry

  • Green “PARRY!” indicator shows the active window

  • Successfully parrying triggers cooldown

  • Orange bar fills up as cooldown progresses

  • Can’t parry again until cooldown completes

pgon1324-cloud

make the PARRY! box dissapear if you fail the parry/dont succesfully parry also reduce knock back and instead of damaging arrow users make it so the arrows get reflected back to the sender same with fireballs (ghast)

Kodari AI
KodariApr 17 at 3:37 pm 9,226 (v2)

I’ll update the mod to add projectile reflection and improve the parry indicator behavior.

Perfect! I’ve updated the Combat Parry mod with all your requested features:

Changes Made:

  1. PARRY! indicator auto-disappears - If you don’t successfully parry within the 300ms window, the green indicator automatically clears

  2. Reduced knockback - Lowered from 1.5 to 0.6 for less aggressive knockback on melee parries

  3. Arrow reflection - Arrows are now reversed and sent back to the shooter at 1.5x speed with critical damage enabled

  4. Fireball reflection - Ghast fireballs and other projectiles are reflected back to their source

  5. Projectile ownership transfer - Reflected projectiles now belong to you, so they damage the original attacker

The system now distinguishes between melee attacks (damage + knockback) and projectiles (full reflection), making parrying more strategic and rewarding against ranged enemies!

pgon1324-cloud

the arrows dont get sent back when i parry them

Kodari AI
KodariApr 17 at 3:42 pm 7,829 (v2)

I see the issue - the damage event fires AFTER the arrow hits, which is too late to reflect it. We need to intercept projectiles BEFORE they collide. Let me fix this with a tick-based projectile detection system.

Perfect! I’ve fixed the arrow reflection system. The key changes:

What was wrong:

  • The old system tried to reflect projectiles in the damage event, which fires AFTER the arrow already hit (too late)

What’s fixed:

  1. Server Tick Detection - Now checks every tick for nearby projectiles within 2.5 blocks during active parry window

  2. Direction Check - Verifies the projectile is actually heading towards the player (dotProduct > 0.5)

  3. Early Reflection - Reflects projectiles BEFORE they hit, reversing their velocity at 1.5x speed

  4. Proper Ownership - Sets the player as the new owner so reflected arrows damage the original shooter

Now arrows, fireballs, and other projectiles will be properly reflected back at attackers when you parry!

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
14 599
src/client/java/com/combatparry/CombatParryClient.java
package com.combatparry;

import com.combatparry.client.ParryClientState;
import com.combatparry.client.ParryHudRenderer;
import com.combatparry.network.ParryStatePayload;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;

public class CombatParryClient implements ClientModInitializer {
    
    @Override
    public void onInitializeClient() {
        ClientPlayNetworking.registerGlobalReceiver(ParryStatePayload.ID, (payload, context) -> {
            if (payload.isActive()) {
                ParryClientState.setParryActive(true);
            } else if (payload.cooldownEndTime() > 0) {
                ParryClientState.setCooldownEndTime(payload.cooldownEndTime());
            } else {
                ParryClientState.clearParry();
            }
        });

        ParryHudRenderer.register();
    }
}