My plan is to increase my sword's damage every time I kill a certain mob...
let $ItemAttributeModifierEvent = Java.loadClass("net.neoforged.neoforge.event.ItemAttributeModifierEvent");
[...]
let bonus = 0.5;
NativeEvents.onEvent($ItemAttributeModifierEvent, e => {
let { itemStack } = e;
let modifierId = itemStack.id + "_penguin_slayer";
// e.addModifier("minecraft:generic.attack_damage", { id: modifierId, amount: bonus, operation: 'add_value'}, 'mainhand');
})
EntityEvents.death('livingthings:penguin', e => {
let { source, entity, server } = e
let killer = source.actual
if (killer && killer.mainHandItem.id === 'owlery:joe_sword') {
e.addModifier("minecraft:generic.attack_damage", { id: modifierId, amount: bonus, operation: 'add_value'}, 'mainhand');
}
})
However, I can't call e.addModifier from EntityEvents.death obviously.
Also the modifierId has no way to transfer to EntityEvents.death too.
Is there other way to make the sword gain damage after killing mobs?
(My plan was to make the sword have a counter that it will increase the damage every 20 penguin kills, but first I want to figure out how to make the damage increase at all.)