#passing in a vector3 when I need to change one value?

1 messages · Page 1 of 1 (latest)

smoky cradle
#

Here is what I have so far however in victimLeftBlock I pass in victimLeft which is not a vector3 but just the the x value minus 1. I don't know how I would pass in the whole vector3 with just the x subtracted by 1. Any help is appreciated thx in advance!
'''js
import {world} from "@minecraft/server"

world.beforeEvents.entityHurt.subscribe((event) => {
const victim = event.hurtEntity
const getVictimTags = victim.getTags()
if (getVictimTags.includes("b_trinkets:void_eyes_cooldown")) {
return
}
if (getVictimTags.includes("b_trinkets:void_eyes")) {
event.cancel
const victimLocation = victim.location
const victimLeft = victim.location.x - 1
const victimRight = victim.location.x + 1
const victimLeftBlock = victim.dimension.getBlock(victimLeft)
if(victimLeftBlock.typeId === "minecraft:air") {
victim.teleport(victimLeft)
}

}

})
'''

#
import {world} from "@minecraft/server"

world.beforeEvents.entityHurt.subscribe((event) => {
    const victim = event.hurtEntity
    const getVictimTags = victim.getTags()
    if (getVictimTags.includes("b_trinkets:void_eyes_cooldown")) {
        return
    }
    if (getVictimTags.includes("b_trinkets:void_eyes")) {
        event.cancel
        const victimLocation = victim.location
        const victimLeft = victim.location.x - 1
        const victimRight = victim.location.x + 1
        const victimLeftBlock = victim.dimension.getBlock(victimLeft)
        if(victimLeftBlock.typeId === "minecraft:air") {
            victim.teleport(victimLeft)
        }

    }
})
slender raptor
#

Is this what you are looking for?

import {world} from "@minecraft/server"

world.beforeEvents.entityHurt.subscribe((event) => {
    const victim = event.hurtEntity
    const getVictimTags = victim.getTags()
    if (getVictimTags.includes("b_trinkets:void_eyes_cooldown")) {
        return
    }
    if (getVictimTags.includes("b_trinkets:void_eyes")) {
        event.cancel
        const victimLocation = victim.location
        victimLocation.x-=1
        const victimLeftBlock = victim.dimension.getBlock(victimLocation)
        if(victimLeftBlock.typeId === "minecraft:air") {
            victim.teleport(victimLeft)
        }

    }
})
smoky cradle
#

oh so your changing the value after you save in the next line?

#

im doing something different I got it to work as such