Why is my block code not giving the chosen player the items?

Started by Rednas2 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Why is my block code not giving the chosen player the items?

I'm making a mod for me and my friends where one person becomes the hunter, gets 8 minutes to hunt us down, and when a command is ran it assigns a random player as the hunter. Part of the code works, i know that bcuz it sends the message i put in the procedure, but it fails somewhere in my code. since i cant upload images, ill try to type down the block code.

Local variables: totalPlayers, a number value. pickIndex, a number value. i, a number value. chosen, an entity.

Send to chat to all players: You get 30 seconds to run!

Send to chat to all players: Survive 8 minutes and win!

Set number Local: totalPlayers to 0

For each player in the current world as EntityIterator

-Set number Local: totalPlayers to [[Get number Local: totalplayers] + 1]

Set number Local: pickIndex to [Random integer between min: 1 and max: [Get number Local:totalPlayers] included]

For each player in the current world as Entity iterator

-Set number Local: pickIndex to [[Get number Local: totalPlayers] + 1]

-If[[Get number Local: i] = [Get number Local: pickIndex]]

--Set entity Local: chosen to Entity Iterator

--Add 1 [item] to Entity Iterator inventory

--Add 1 [item] to Entity Iterator inventory

--Add 1 [item] to Entity Iterator inventory

--Add potion Slowness with level 255 for 1200 ticks ambient false particles true to entity iterator

--Add potion Blindness with level 255 for 1200 ticks ambient false particles true to entity iterator