#entity except player on beforechat event

1 messages · Page 1 of 1 (latest)

smoky cedar
#

How to get the entity in the beforeChat event other than player, for example the entity needed is an entity with typeid custom:test, then it can be used to change the nametag of the entity

smoky cedar
#

.

terse goblet
#

player.dimension.getEntity()

smoky cedar
small minnowBOT
#
Debug Result

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

<repl>.js:1:1 - error TS2304: Cannot find name 'For'.

1 For(const player of world.getPlayer()) {
  ~~~
<repl>.js:1:5 - error TS1135: Argument expression expected.

1 For(const player of world.getPlayer()) {
      ~~~~~
<repl>.js:1:18 - error TS1005: ';' expected.

1 For(const player of world.getPlayer()) {
                   ~~
<repl>.js:1:18 - error TS2304: Cannot find name 'of'.

1 For(const player of world.getPlayer()) {
                   ~~
<repl>.js:1:27 - error TS2551: Property 'getPlayer' does not exist on type 'World'. Did you mean 'getPlayers'?

1 For(const player of world.getPlayer()) {
                            ~~~~~~~~~

  @minecraft/server.d.ts:3526:13
    3526             getPlayers(options?: EntityQueryOptions): Player[];
                     ~~~~~~~~~~
    'getPlayers' is declared here.
<repl>.js:1:38 - error TS1005: ';' expected.

1 For(const player of world.getPlayer()) {
                                       ~

#
Debug Result

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

<repl>.js:2:31 - error TS2339: Property 'getEntity' does not exist on type 'Dimension'.

2 let entity = player.dimension.getEntity('custom:test');
                                ~~~~~~~~~

terse goblet
small minnowBOT
#
Debug Result

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

<repl>.js:2:20 - error TS2552: Cannot find name 'player'. Did you mean 'Player'?

2 world.getDimension(player.dimension.id).getEntities({ type: 'custom:test' }).forEach((entity) => {
                     ~~~~~~

  @minecraft/server.d.ts:3318:15
    3318         class Player extends Entity {
                       ~~~~~~
    'Player' is declared here.
<repl>.js:2:78 - error TS2339: Property 'forEach' does not exist on type 'EntityIterator'.

2 world.getDimension(player.dimension.id).getEntities({ type: 'custom:test' }).forEach((entity) => {
                                                                               ~~~~~~~

#
Debug Result

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

<repl>.js:2:83 - error TS2339: Property 'forEach' does not exist on type 'EntityIterator'.

2 world.getDimension(data.sender.dimension.id).getEntities({ type: 'custom:test' }).forEach((entity) => {
                                                                                    ~~~~~~~

terse goblet
#

huh

small minnowBOT
#
No Errors

No errors in [code](#1086268499057447003 message)

terse goblet
#

there @smoky cedar