#It's not working, help me?

1 messages · Page 1 of 1 (latest)

hard lichenBOT
#
Debug Result

There are errors in this [code](#1072943733374472272 message):

<repl>.js:4:47 - error TS2339: Property 'damagingEntity' does not exist on type 'EntityHurtEvent'.

4   if (event.hurtEntity === undefined || event.damagingEntity === undefined) return;
                                                ~~~~~~~~~~~~~~
<repl>.js:7:21 - error TS2339: Property 'damagingEntity' does not exist on type 'EntityHurtEvent'.

7     Batedor = event.damagingEntity,
                      ~~~~~~~~~~~~~~

#
Debug Result

There are errors in this [code](#1072943733374472272 message):

<repl>.js:4:47 - error TS2339: Property 'damagingEntity' does not exist on type 'EntityHurtEvent'.

4   if (event.hurtEntity === undefined || event.damagingEntity === undefined) return;
                                                ~~~~~~~~~~~~~~
<repl>.js:7:21 - error TS2339: Property 'damagingEntity' does not exist on type 'EntityHurtEvent'.

7     Batedor = event.damagingEntity,
                      ~~~~~~~~~~~~~~

trail heath
#

has the damagingEntity changed?

twilit socket
#

theres hitEntity

#

sorry

#

source

#

damageSource

trail heath
#

@twilit socket

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

world.events.entityHurt.subscribe((event) => {
  if (event.hurtEntity === undefined || event.EntityDamageSource === undefined) return;
  const
    Dano = event.damage,
    Batedor = event.EntityDamageSource,
    Apanhador = event.hurtEntity,
    inventory = Batedor.getComponent("inventory"),
    container = inventory.container,
    hand = container.getItem(Batedor.selectedSlot);
  if (!Apanhador.hasTag("empty")) {
    Apanhador.runCommandAsync(`say §c-${Dano}`);
    Apanhador.runCommandAsync(`summon wesl3y:health ~~1~ minecraft:entity_spawned §c-${Dano}`);
    Batedor.runCommandAsync(`say Batedor`);
  }
});
#

still does not work :/

trail heath
#

I didn't understand

cursive breach
trail heath
#

Official version, 1.19.60

hard lichenBOT
#
Debug Result

There are errors in this [code](#1072943733374472272 message):

<repl>.js:4:47 - error TS2551: Property 'EntityDamageSource' does not exist on type 'EntityHurtEvent'. Did you mean 'damageSource'?

4   if (event.hurtEntity === undefined || event.EntityDamageSource === undefined) return;
                                                ~~~~~~~~~~~~~~~~~~

  @minecraft/server.d.ts:4667:18
    4667         readonly damageSource: EntityDamageSource;
                          ~~~~~~~~~~~~
    'damageSource' is declared here.
<repl>.js:7:21 - error TS2551: Property 'EntityDamageSource' does not exist on type 'EntityHurtEvent'. Did you mean 'damageSource'?

7     Batedor = event.EntityDamageSource,
                      ~~~~~~~~~~~~~~~~~~

  @minecraft/server.d.ts:4667:18
    4667         readonly damageSource: EntityDamageSource;
                          ~~~~~~~~~~~~
    'damageSource' is declared here.

cursive breach
#
import { world } from "@minecraft/server";

world.events.entityHit.subscribe((event) => {
  if (!event.hitEntity) return;
  const
    Batedor = event.entity,
    Apanhador = event.hitEntity,
    inventory = Batedor.getComponent("inventory"),
    container = inventory.container,
    hand = container.getItem(Batedor.selectedSlot);
  if (!Apanhador.hasTag("empty")) {
    Apanhador.runCommandAsync(`say §c-${Dano}`);
    Apanhador.runCommandAsync(`summon wesl3y:health ~~1~ minecraft:entity_spawned §c-${Dano}`);
    Batedor.runCommandAsync(`say Batedor`);
  }
});
hard lichenBOT
#
Debug Result

There are errors in this [code](#1072943733374472272 message):

<repl>.js:9:25 - error TS2339: Property 'getComponent' does not exist on type 'EntityDamageSource'.

9     inventory = Batedor.getComponent("inventory"),
                          ~~~~~~~~~~~~
<repl>.js:11:38 - error TS2339: Property 'selectedSlot' does not exist on type 'EntityDamageSource'.

11     hand = container.getItem(Batedor.selectedSlot);
                                        ~~~~~~~~~~~~
<repl>.js:15:13 - error TS2339: Property 'runCommandAsync' does not exist on type 'EntityDamageSource'.

15     Batedor.runCommandAsync(`say Batedor`);
               ~~~~~~~~~~~~~~~

trail heath
#

What I have to do?

twilit socket
#

use his codr

trail heath
#

from who?

#

ahhh

#

I saw it now, I'm blind

hard lichenBOT
#
Debug Result

There are errors in this [code](#1072943733374472272 message):

<repl>.js:10:38 - error TS2339: Property 'selectedSlot' does not exist on type 'Entity'.

10     hand = container.getItem(Batedor.selectedSlot);
                                        ~~~~~~~~~~~~
<repl>.js:12:41 - error TS2304: Cannot find name 'Dano'.

12     Apanhador.runCommandAsync(`say §c-${Dano}`);
                                           ~~~~
<repl>.js:13:88 - error TS2304: Cannot find name 'Dano'.

13     Apanhador.runCommandAsync(`summon wesl3y:health ~~1~ minecraft:entity_spawned §c-${Dano}`);
                                                                                          ~~~~

trail heath
#
import { world } from "@minecraft/server";

world.events.entityHurt.subscribe((event) => {
  if (!event.hurtEntity || !event.damageSource) return;
  const
    Dano = event.damage,
    Batedor = event.damageSource,
    Apanhador = event.hurtEntity,
    inventory = Batedor.getComponent("inventory"),
    container = inventory.container,
    hand = container.getItem(Batedor.selectedSlot);
  if (!Apanhador.hasTag("empty")) {
    Apanhador.runCommandAsync(`say §c-${Dano}`);
    Apanhador.runCommandAsync(`summon wesl3y:health ~~1~ minecraft:entity_spawned §c-${Dano}`);
    Batedor.runCommandAsync(`say Batedor`);
  }
});
#

there was an error

twilit socket
#

what

cursive breach
# trail heath ```js import { world } from "@minecraft/server"; world.events.entityHurt.subscr...
import { world, Player } from "@minecraft/server";

world.events.entityHurt.subscribe((event) => {
  if (!event.damageSource.damagingEntity || !(event.damageSource.damagingEntity instanceof Player)) return;
  const
    Dano = event.damage,
    Batedor = event.damageSource.damagingEntity,
    Apanhador = event.hurtEntity,
    inventory = Batedor.getComponent("inventory"),
    container = inventory.container,
    hand = container.getItem(Batedor.selectedSlot);
  if (!Apanhador.hasTag("empty")) {
    Apanhador.runCommandAsync(`say §c-${Dano}`);
    Apanhador.runCommandAsync(`summon wesl3y:health ~~1~ minecraft:entity_spawned §c-${Dano}`);
    Batedor.runCommandAsync(`say Batedor`);
  }
});
#

Fixed it

trail heath
#

ok

#
import { world, Player } from "@minecraft/server";

world.events.entityHurt.subscribe((event) => {
  if (!event.damageSource.damagingEntity || !(event.damageSource.damagingEntity instanceof Player)) return;
  const
    Dano = event.damage,
    Batedor = event.damageSource.damagingEntity,
    Apanhador = event.hurtEntity,
    inventory = Batedor.getComponent("inventory"),
    container = inventory.container,
    hand = container.getItem(Batedor.selectedSlot);
  if (!Apanhador.hasTag("empty")) {
    Apanhador.runCommandAsync(`summon wesl3y:health ~~1~ minecraft:entity_spawned §c-${Dano}`);
  }
  if (Batedor.typeId == "minecraft:player" && hand.typeId == "wesl3y:fire_sword") {
    Apanhador.runCommandAsync(`tp @s -1 512 26`);
  }
});
hard lichenBOT
#
No errors

No errors in [code](#1072943733374472272 message)

trail heath
#
[Scripting][error]-TypeError: cannot read property 'typeId' of undefined    at <anonymous> (attack.js:17)
#

:/

cursive breach
trail heath
#
import { world, Player } from "@minecraft/server";
import { getScore } from "./modules/general";

world.events.entityHurt.subscribe((event) => {
  if (!event.damageSource.damagingEntity || !(event.damageSource.damagingEntity instanceof Player)) return;
  const
    Dano = event.damage,
    Batedor = event.damageSource.damagingEntity,
    Apanhador = event.hurtEntity,
    inventory = Batedor.getComponent("inventory"),
    container = inventory.container,
    hand = container.getItem(Batedor.selectedSlot);
  if (!Apanhador.hasTag("empty")) {
    Apanhador.runCommandAsync(`summon wesl3y:health ~~1~ minecraft:entity_spawned §c-${Dano}`);
  }
  if (Batedor.typeId == "minecraft:player" && hand.typeId == "wesl3y:quirk_copy") {
    Apanhador.runCommandAsync(`tp @s -1 512 26`);
  }
});
[Scripting][error]-TypeError: cannot read property 'typeId' of undefined    at <anonymous> (attack.js:16)
cursive breach
trail heath
#

1.19.60

trail heath
cursive breach
trail heath
#

Ahh

cursive breach
# trail heath

This is how you add modules to the pack

{
    "module_name": "@minecraft/server",
    "version": "1.1.0-beta"
}
twilit socket
#

why u have uuids

#

xd

cursive breach
twin laurel
#

Why not better use the "entityHit" event.

trail heath
#

I already got it