#help

1 messages · Page 1 of 1 (latest)

wind canyon
#
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`)
    }

    })})```
#

not sure whats wrong

plucky linden
#

whats slot

empty bane
#

item is ItemStack

wind canyon
#

tryn to get what they have in hand?

#

oh

plucky linden
#

and do item.typeId

empty bane
#

uh, i'd use equipment_inventory for mainhand item

#

equipment dont have container

plucky linden
#

@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)
}

})
}) ```

wind canyon
plucky linden
#

oki

wind canyon
# plucky linden 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

empty bane
#

"inventory" there is a ContainerSlot

plucky linden
wind canyon
#

hmm ok let me try

plucky linden
#

did it work

wind canyon
#

hmm not sure hi works tp doesnt

empty bane
#

at least console.warn the variable bruv

wind canyon
#

true

#

lol

plucky linden
#

use js player.teleport({ x: 39, y: -54, z: 7 }, { dimension: world.getDimension("minecraft:overworld") })

#

its faster

#

and better

plucky linden
#

did it work

wind canyon
#

no im messing stuff up

plucky linden
#

whats the error

empty bane
#

i learned debugging, starting from printing the variable in console

empty bane
#

to JSON.stringify() it

#

then to dig deeper

#

the object

wind canyon
#

yeah about to stringify

plucky linden
#

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 ?

wind canyon
#

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
plucky linden
#

it works for me

empty bane
#

entity is string

#

should be an object

wind canyon
#

saysnot a function

if (item == `mrleefy:stack_killer` && entity.includes(validMobs)) {

plucky linden
#

what?

wind canyon
plucky linden
#

what is validMobs

wind canyon
plucky linden
#

oh

wind canyon
#

returns list good

plucky linden
#

douse the code works

#

@wind canyon

wind canyon
#

if (item == mrleefy:stack_killer && entity.includes(validMobs)) {

plucky linden
#

the code work wan i did only minecraft:dirt

#

thats means its the entity.includes(validMobs)

empty bane
#

why not make it despawn tho

plucky linden
#

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)
}

})
}) ```

plucky linden
empty bane
#

i'd put instant despawn component_group on my entities so i could easily delete em when necessary

wind canyon
#

i would do instant despawn this is just temp

empty bane
#

ok...

#

uh, why that coords btw

wind canyon
#

idk random out of the way kinda