#On Hit event?
23 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Hurt is the hit event
And you have damage source in that where you can filter what type of damage, who did it, where, etc
I ask because i'm running into an issue trying to make an Ars Nouveau x Tetra thing. Currently when I attack with a tetra weapon I canst a spell from Ars Nouveau, that part works perfectly. But the issue is that if that spell deals damage, it triggers Hurt again
which then triggers the spell again
and so on and so forth
creating an infinite loop
and sadly Ars spells don't all deal magic damage, in fact most don't
so i can't just filter out magic damage
you mind if i share the event here?
maybe someone can figure out a way to handle this
EntityEvents.hurt(event => {
let source = event.source.getActual();
let target = event.entity;
if ( source && source.isPlayer()) {
let main_hand = source.mainHandItem;
let off_hand = source.offHandItem;
for ( let hand of [main_hand, off_hand] ) {
if ( hand && hand.getItem() instanceof ModularItem ) {
let sourceLeechLevel = hand.getItem().getEffectLevel(hand, ItemEffect.get("source_leech"));
let spellstriker = hand.getItem().getEffectLevel(hand, ItemEffect.get("spellstrike"));
if (sourceLeechLevel > 0) {
console.info("Instance of Source Leech!");
ArsCapability.getMana(source).ifPresent(mana => mana.addMana(5 * sourceLeechLevel));
}//if player is wielding a source leech item
if (spellstriker > 0 && !source.potionEffects.isActive('tetra:spellstrike_fatigue')) {
console.info("Instance of Spellstriker!");
let reactive = new SpellCaster(hand);
let caster = new PlayerCaster(source);
let spell = reactive.modifySpellBeforeCasting(source.getCommandSenderWorld(), source, InteractionHand.MAIN_HAND, reactive.getSpell());
source.addEffect(new MobEffectInstance('tetra:spellstrike_fatigue', 25)); // Anti-infinite-loop measures.
let spellContext = new SpellContext(source.getCommandSenderWorld(), spell, source, caster);
let resolver = new SpellResolver(spellContext);
resolver.onCastOnEntity(hand, target, InteractionHand.MAIN_HAND);
}//if player is wielding a spellstriker weapon, cast a spell.
}//if the weapon is a modular weapon
}
}//if damage was done by a player
})```
The potioneffect is my current work-around
It basically adds a cooldown between triggers of the spell
but this is what we in the business like to call Jank™️
so i want to find a true solution
You could use a cooldown thing, so when you deal damage you put a tag on the enemy, then after X ticks you remove it with a schedule
When you deal damage you look for that tag and cancel the event if the tag is present
i mean that's what i'm doing now, but it feels like a mega jank solution