Detect non-critical hits

Started by Orandza on

Topic category: Help with Minecraft modding (Java Edition)

Active 5 months ago
Joined Jul 2022
Points:
486

User statistics:

  • Modifications: 0
  • Forum topics: 14
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 29
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?

Active 1 year ago
Joined Mar 2020
Points:
1537

User statistics:

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

How do you detect critical hits?

Active 4 months ago
Joined Jan 2021
Points:
739

User statistics:

  • Modifications: 2
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 198
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

Active 3 weeks ago
Joined Mar 2019
Points:
825

User statistics:

  • Modifications: 4
  • Forum topics: 10
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 137
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

Active 3 weeks ago
Joined Mar 2019
Points:
825

User statistics:

  • Modifications: 4
  • Forum topics: 10
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 137
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.

Active 5 months ago
Joined Jul 2022
Points:
486

User statistics:

  • Modifications: 0
  • Forum topics: 14
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 29
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.

Active 4 months ago
Joined Jan 2021
Points:
739

User statistics:

  • Modifications: 2
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 198
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?

Active 1 year ago
Joined Oct 2021
Points:
610

User statistics:

  • Modifications: 0
  • Forum topics: 7
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 121
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. 

Active 1 year ago
Joined Oct 2021
Points:
610

User statistics:

  • Modifications: 0
  • Forum topics: 7
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 121
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);

Active 1 year ago
Joined Oct 2021
Points:
610

User statistics:

  • Modifications: 0
  • Forum topics: 7
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 121
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);

Active 5 months ago
Joined Jul 2022
Points:
486

User statistics:

  • Modifications: 0
  • Forum topics: 14
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 29
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.

Active 5 months ago
Joined Jul 2022
Points:
486

User statistics:

  • Modifications: 0
  • Forum topics: 14
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 29
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