#Trying to acces dimensions

1 messages · Page 1 of 1 (latest)

idle granite
#
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?

#

kind of fixed it now

#

but it still give the error

#
mc.world.afterEvents.effectAdd.subscribe(data=> {
        if (data.entity.getEffect('blindness') && data.entity.hasTag('blinded')) {
                mc.world.sendMessage(data.entity.typeId + " is blinded");  
        }
        else{
            console.warn('notblinded');
        }
})

mc.world.afterEvents.entityHurt.subscribe(data=> {
    function getRandomInt(max) {
        return Math.floor(Math.random() * max);
    }
    const allDimensions = [
        'overworld', 'nether', 'the_end'
    ]
    
    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);
            world.getDimension(dimension).spawnEntity('minecraft:lightning_bolt',entityLoc)
            
            
        }
            else{
                console.warn('urnotanirongolem');
            }
    }
})

I fixed it now it summons the lightning bolt but it still says the error

idle granite
#

I think I get how it works now