#Adding an Array, and applying it

1 messages · Page 1 of 1 (latest)

languid quartz
#

can someone help me fix my code so the arrays will work with type id and not just the mrleefy:cowstill mob??

solid elk
#

where are you applying it?

languid quartz
#

i have it as the cow entity, i need to make it dynamic

#

just search mrleefy:cowstill and its pretty much in those spots

solid elk
#

like

if (evd.hurtEntity.getComponent("health").current <= 0)
#

thats where you want it?

languid quartz
#

the hurtEntity is already defined, i just need to edit the definitions. Let me get a clip

#
const entity = dimension.spawnEntity('mrleefy:cowstill', new Location(x, y, z))

and here

system.runSchedule(() => {
  const entities = world.getDimension("overworld").getEntities({type: 'mrleefy:cowstill'})

solid elk
#

i dont really understand but

world.events.entityHurt.subscribe(evd => {
    const damaginEntity = evd.damagingEntity
    const mobs = [`minecraft:creeper`, `minecraft:skeleton`, `minecraft:spider`, `minecraft:zombie`, `minecraft:blaze`]
    const hurtEntity = evd.hurtEntity
    if (hurtEntity.getComponent("health").current <= 0 && mobs.includes(hurtEntity.typeId)) {
      damaginEntity.runCommandAsync('scoreboard players add @s currentXP 10')
        }
    }
)```
 i just had a similar issue and this is waht the working array looks like for mine so
#

ifk if this will help you or now

languid quartz
#

oh okay let me take a look

solid elk
#
mobs.includes(hurtEntity.typeId)
``` this is where the array is used
#
const mobs = [`minecraft:creeper`, `minecraft:skeleton`, `minecraft:spider`, `minecraft:zombie`, `minecraft:blaze`]
``` and this is where its defined
languid quartz
#

awh yes that might just work, just use same type of thing

#

mobs.includes(

languid quartz
#

got it yay