import {
system, world
} from "@minecraft/server";
world.afterEvents.entityHitEntity.subscribe(evd => {
system.run(() => {
const player = evd.damagingEntity
const inventory = player.getComponent("equipment_inventory").container;
const item = inventory.getItem(slot)
if(item == `mrleefy:stack_killer`){
player.runCommand(`say hi`)
}
})})```
#help
1 messages · Page 1 of 1 (latest)
whats slot
item is ItemStack
and do item.typeId
@wind canyon ```js
import {
system, world
} from "@minecraft/server";
world.afterEvents.entityHitEntity.subscribe(evd => {
system.run(() => {
const player = evd.damagingEntity
const inventory = player.getComponent("equipment_inventory").getEquipmentSlot('mainhand')
const item = inventory.typeId
if (item == mrleefy:stack_killer) {
player.runCommand(say hi)
}
})
}) ```
try this @wind canyon
works perfectly thank you!
oki
import {
system, world
} from "@minecraft/server";
import { validMobs } from "./mobstacker";
world.afterEvents.entityHitEntity.subscribe(evd => {
system.run(() => {
const player = evd.damagingEntity
const entity = evd.hitEntity
const inventory = player.getComponent("equipment_inventory").getEquipmentSlot('mainhand')
const item = inventory.typeId
if (item.typeId == `mrleefy:stack_killer` && entity.includes(validMobs)) {
player.runCommand(`say hi`)
entity.runCommand(`tp @s 9999999 -9999999 9999999`)
}
})
}) ```
no errors and entity doesnt teleport
"inventory" there is a ContainerSlot
mm
hmm ok let me try
did it work
hmm not sure hi works tp doesnt
at least console.warn the variable bruv
use js player.teleport({ x: 39, y: -54, z: 7 }, { dimension: world.getDimension("minecraft:overworld") })
its faster
and better
no im messing stuff up
whats the error
i learned debugging, starting from printing the variable in console
same
yeah about to stringify
try this ```js
world.afterEvents.entityHitEntity.subscribe(evd => {
system.run(() => {
const player = evd.damagingEntity
const entity = evd.hitEntity
const inventory = player.getComponent("equipment_inventory").getEquipmentSlot('mainhand')
const item = inventory.typeId
if (item == mrleefy:stack_killer && entity.includes(validMobs)) {
player.runCommand(say hi)
entity.runCommandAsync(tp @s 9999999 -9999999 9999999)
}
})
}) ```
it work for me
@wind canyon did it work ?
i did some digging for practice
import {
system, world
} from "@minecraft/server";
import { validMobs } from "./mobstacker";
world.afterEvents.entityHitEntity.subscribe(evd => {
system.run(() => {
const player = evd.damagingEntity
const entity = evd.hitEntity.typeId
const inventory = player.getComponent("equipment_inventory").getEquipmentSlot('mainhand')
const item = inventory.typeId
console.warn(item)
console.warn(JSON.stringify(entity))
console.warn(JSON.stringify(validMobs))
if (item == `mrleefy:stack_killer` && entity.includes(validMobs)) {
player.runCommand(`say hi`)
entity.teleport({ x: 39, y: -54, z: 7 }, { dimension: world.getDimension("minecraft:overworld") })
}
})
})
``` added typeId end of entity definition but commands dont run
it works for me
saysnot a function
if (item == `mrleefy:stack_killer` && entity.includes(validMobs)) {
what?
hmm ok
what is validMobs
list of entities that stack for my custom spawners
oh
returns list good
yours says not a function at line 12
if (item == mrleefy:stack_killer && entity.includes(validMobs)) {
the code work wan i did only minecraft:dirt
thats means its the entity.includes(validMobs)
why not make it despawn tho
oh do ```js
world.afterEvents.entityHitEntity.subscribe(evd => {
system.run(() => {
const player = evd.damagingEntity
const entity = evd.hitEntity
const inventory = player.getComponent("equipment_inventory").getEquipmentSlot('mainhand')
const item = inventory.typeId
if (item == mrleefy:stack_killer && entity?.typeId.includes(validMobs)) {
player.runCommand(say hi)
entity.runCommandAsync(tp @s 9999999 -9999999 9999999)
}
})
}) ```
idk
i'd put instant despawn component_group on my entities so i could easily delete em when necessary
did you
ah
i would do instant despawn this is just temp
idk random out of the way kinda