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

[Bug|Crash]: knockBackEntity Not working properly,Like guard skills #1918

Open
4 tasks done
PraiseSuffering opened this issue Feb 10, 2025 · 0 comments
Open
4 tasks done

Comments

@PraiseSuffering
Copy link

Please check if a similar issue has already been reported.

  • I checked this type of issue has never been reported.

Please check you're using proper versions.

  • I checked all of them in the right version.

Please check if this issue's from out of our area

  • I understood the problem.

The name of the mod

No response

After all of these, please check if you're just pressing the ok buttons to skip this process.

  • I read the checklist and I promise I'll provide all the information that is needed to fix the issue

Minecraft Version

1.20.1

The Issue

yesman.epicfight.world.capabilities.entitypatch.HurtableEntityPatch#knockBackEntity Not working properly

Use this
((LivingEntity)this.original).hurtMarked= true;

Test code
@mixin(HurtableEntityPatch.class)
public abstract class MixinHurtableEntityPatch extends EntityPatch {

/**
 * @author
 */
@Overwrite
public void knockBackEntity(Vec3 sourceLocation, float power) {
    double d1 = sourceLocation.x() - ((LivingEntity)this.original).getX();

    double d0;
    for(d0 = sourceLocation.z() - ((LivingEntity)this.original).getZ(); d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D) {
        d1 = (Math.random() - Math.random()) * 0.01D;
    }

    power = (float)((double)power * (1.0D - ((LivingEntity)this.original).getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)));
    if ((double)power > 0.0D) {
        ((LivingEntity)this.original).hasImpulse = true;
        ((LivingEntity)this.original).hurtMarked = true;//对,不知道是他反混淆名有问题还是怎么着,加上这行才行
        Vec3 vec3 = ((LivingEntity)this.original).getDeltaMovement();
        Vec3 vec31 = (new Vec3(d1, 0.0D, d0)).normalize().scale((double)power);
        ((LivingEntity)this.original).setDeltaMovement(vec3.x / 2.0D - vec31.x, ((LivingEntity)this.original).onGround() ? Math.min(0.4D, vec3.y / 2.0D) : vec3.y, vec3.z / 2.0D - vec31.z);
    }

}

}

Steps to Reproduce

guard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant