Detect non-critical hits

Started by Orandza on

Topic category: Help with modding (Java Edition)

Last seen on 01:31, 19. Apr 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Detect non-critical hits

I would like to add a challenge rule to the game that, when enabled, will prevent you from dealing damage to entities unless you perform a critical hit. However, mcreator only seems to have a way of detecting when you deal a critical hit, not the other way around. I tried using custom variables and stuff, nothing seemed to work. Any ideas?

Last seen on 00:42, 10. Oct 2023
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do you detect critical…
Mon, 01/09/2023 - 00:16

How do you detect critical hits?

Last seen on 20:35, 18. Apr 2024
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Have not tried it but maybe…
Mon, 01/09/2023 - 03:40

Have not tried it but maybe cancel the event, see if that works

Last seen on 17:44, 18. Apr 2024
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
try detecting if the…
Mon, 01/09/2023 - 05:45

try detecting if the attacker has negative Y speed and is the Y coordinate higher than the attacked entity

since this is the way a critical hit is dealed. should work

Last seen on 17:44, 18. Apr 2024
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
also. i thing would be…
Mon, 01/09/2023 - 05:56

also. i thing would be harder if the player couldn't deal critical hits. since i pve is easier to just use criticals.

Last seen on 01:31, 19. Apr 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks, since I am adding…
Mon, 01/09/2023 - 11:44

Thanks, since I am adding challenge modes to my mod, I could add that too(crit shots disabled). And thanks for the help. However your Y coordinate being higher than the attacked entity is not a requirement for dealing critical hits, I just tested that. The first thing you mentioned is true tho. And it gave me an idea, I will check the minecraft wiki for everything required to deal a critical hit and I will use those requirements to prevent the player from dealing damage if they don't fulfill everything.

That being said, I am not sure how to check weapon cooldown...

McModded1.14 - you detect them with the player deals critical hit procedure.

Suddz - the problem is not cancelling, the problem is detecting when the event should be cancelled.

Last seen on 20:35, 18. Apr 2024
Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Could not figure it out. But…
Mon, 01/09/2023 - 17:45

Could not figure it out. But i might have looked at it wrong, your idea is to only be able do deal critical stikes and not normal attacks when a gamemode/debuff is active?

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Trigger "Player deals…
Tue, 01/17/2023 - 19:51

Trigger "Player deals critical hit" is called every hit, before minecraft calculates if hit should be critical. 

However it provides logic dependency "isvanillacritical" which is true when hit will be calculated as critical by vanilla minecraft. Otherwise it will be false. 

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sadly i can't be canceled,…
Tue, 01/17/2023 - 20:52

Sadly i can't be canceled, but you can remove damage (there are still particles generated, but no damage is done). Just small code snippet:

((CriticalHitEvent) event).setDamageModifier(0);

Last seen on 15:21, 16. Oct 2023
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sadly i can't be canceled,…
Tue, 01/17/2023 - 20:53

Sadly i can't be canceled, but you can remove damage (there are still particles generated, but no damage is done). Just small code snippet:

((CriticalHitEvent) event).setDamageModifier(0);

Last seen on 01:31, 19. Apr 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes Suddz, that's what I…
Sat, 02/11/2023 - 23:20

Yes Suddz, that's what I meant. And it would be for a gamerule.

Azzier,

Thanks, although that sounds like the opposite of what I want to achieve. I want to remove damage from any non-critical attack rather than getting rid of crits.

Last seen on 01:31, 19. Apr 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Though I might just be…
Sat, 02/11/2023 - 23:21

Though I might just be misunderstanding you. If I am, let me know. I'll still try this out myself sometime