Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] allow CriticalHitEvent to not disable sweep when set to criticalHit #1313

Closed
lcy0x1 opened this issue Jul 15, 2024 · 3 comments · Fixed by #1496
Closed
Labels
1.21.1 Targeted at Minecraft 1.21.1 enhancement New (or improvement to existing) feature or request

Comments

@lcy0x1
Copy link
Contributor

lcy0x1 commented Jul 15, 2024

Vanilla logic:

  1. check if player can perform critical hit (flag1)
  2. apply critical hit bonus
  3. check if player can sweep attack (flag2), which requires player to not be able to critical hit in vanilla sense

Current NeoForge logic:
Directly modifies flag1 when mods enables critical hit. This disables sweep attack unintentionally. The suggested behavior is to use the vanilla critical hit flag for sweep attack check, which means changing the following code:

var critEvent = net.neoforged.neoforge.common.CommonHooks.fireCriticalHit(this, target, flag1, flag1 ? 1.5F : 1.0F);
flag1 = critEvent.isCriticalHit();
if (flag1) {
    f *= critEvent.getDamageMultiplier();
}

float f3 = f + f1;
boolean flag2 = false;
double d0 = (double)(this.walkDist - this.walkDistO);
if (flag4 && !flag1 && !flag && this.onGround() && d0 < (double)this.getSpeed()) {
    ItemStack itemstack1 = this.getItemInHand(InteractionHand.MAIN_HAND);
    flag2 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_SWEEP);
}

to

var critEvent = net.neoforged.neoforge.common.CommonHooks.fireCriticalHit(this, target, flag1, flag1 ? 1.5F : 1.0F);
boolean disableSweep = flag1;
flag1 = critEvent.isCriticalHit();
if (flag1) {
    f *= critEvent.getDamageMultiplier();
}

float f3 = f + f1;
boolean flag2 = false;
double d0 = (double)(this.walkDist - this.walkDistO);
if (flag4 && !disableSweep && !flag && this.onGround() && d0 < (double)this.getSpeed()) {
    ItemStack itemstack1 = this.getItemInHand(InteractionHand.MAIN_HAND);
    flag2 = itemstack1.canPerformAction(net.neoforged.neoforge.common.ItemAbilities.SWORD_SWEEP);
}

Alternative solutions such as adding whether to disable sweep as part of CriticalHitEvent would also address this issue.

@ChampionAsh5357
Copy link
Contributor

I feel like I'm misunderstanding the issue. If a critical hit occurs, then the sweep attack is disabled, as that is vanilla behavior.

Is this supposed to be a bug report, or a feature request to add the ability to crit and handle a sweep attack? The way it's currently being described is as a bug when it is not.

@lcy0x1
Copy link
Contributor Author

lcy0x1 commented Aug 30, 2024

This is a feature request to allow crit to not disable sweep in some cases. I will edit the title and description

@lcy0x1 lcy0x1 changed the title CriticalHitEvent disables sweep when set to criticalHit [Feature Request] allow CriticalHitEvent to not disable sweep when set to criticalHit Aug 30, 2024
@sciwhiz12 sciwhiz12 added enhancement New (or improvement to existing) feature or request 1.21.1 Targeted at Minecraft 1.21.1 labels Sep 6, 2024
@neoforged-releases
Copy link

🚀 This issue has been resolved in NeoForge version 21.1.61, as part of #1496.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.1 Targeted at Minecraft 1.21.1 enhancement New (or improvement to existing) feature or request
Projects
None yet
3 participants