#Killing specific entity will give you different points
1 messages · Page 1 of 1 (latest)
let low = [ "zombie", "creeper"]
if(entityhurt.includes(low)) return point = 1
Use event entityHurt
no
Then
I want it like this
const entity = {
"minecraft:zombie": 1,
"minecraft:skeleton": 2
}
if (victim.includes(entity) && initiator.typeId("minecraft:player"))
player.runCommandAsync("scoreboard players add @s gold //the point in the entity variable")
Owh
Does it work on swords or other things?
@dry kiln ```js
const entity = {
"minecraft:zombie": 1,
"minecraft:spider": 2,
"minecraft:skeleton": 3
}
world.events.entityHurt.subscribe((data) => {
const {
hurtEntity: victim,
damageSource: {
cause,
damagingEntity: initiator,
damagingProjectile: projectile
}
} = data;
const { current } = victim.getComponent('health')
if (current > 0 || initiator?.typeId !== 'minecraft:player') return;
const scorePoints = entity[victim.typeId] ?? 0
initiator.runCommandAsync(scoreboard players add @s gold ${scorePoints})
switch (cause) {
case 'projectile':
initiator.runCommandAsync('say '+cause)
projectile.runCommandAsync('say '+cause)
break;
case 'entityAttack':
initiator.runCommandAsync('say '+cause)
break;
case 'magic':
initiator.runCommandAsync('say '+cause)
break;
case 'thorns':
initiator.runCommandAsync('say '+cause)
break;
}
})
Do i put runCommandAsync on each of them?
do u want it only working in player?
Yes, the initiator
there
No errors in [code](#1076438191747371049 message)
Can you tell whats gonna happen and why there projectiles projectile.runCommandAsync
the switch (cause) part is just extra code if u want to run something when specific dmg cause was dealt
either remove oif u dont need it or add somethin there.
Both ways works
Sadly the thorns don't work