Started by
Orandza
on
Topic category: Help with Minecraft modding (Java Edition)
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?
How do you detect critical hits?
Have not tried it but maybe cancel the event, see if that works
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
also. i thing would be harder if the player couldn't deal critical hits. since i pve is easier to just use criticals.
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.
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?
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.
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);
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);
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.
Though I might just be misunderstanding you. If I am, let me know. I'll still try this out myself sometime