mc.world.afterEvents.entityHurt.subscribe(data=> {
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
const allDimensions = [
mc.world.getDimension("the_end"),
mc.world.getDimension("nether"),
mc.world.getDimension("overworld")
]
const entityLoc = data.damageSource.damagingEntity.location
entityLoc.x += getRandomInt(6)
entityLoc.Y += getRandomInt(6)
for (const dimension of allDimensions) {
if (data.damageSource.damagingEntity.hasTag('ironGolem')) {
data.hurtEntity.applyKnockback(0,0,1,1);
dimension.spawnEntity('minecraft:lightning_bolt',entityLoc)
}
else{
console.warn('urnotanirongolem');
}
}
})
where di I go wrong?