r/minecraftbedrock • • 5d ago

Commands A "/give random item" I Made Using Over 2000 Command Blocks in Bedrock Edition

Finally finished the random item generator for my minigame (It's about 2200 command blocks alone)

67 Upvotes

19 comments sorted by

4

u/TabouletVR 5d ago

Cool stuff but i feel like you could've just made a behavior pack that did that

4

u/Over_Walk3859 5d ago

I'm on the nintendo switch, so that's not really possible for me

3

u/Prokazu 5d ago

You can play pillars of fortune with friends now in your world 👏

3

u/Over_Walk3859 5d ago

That was the idea, yeah!

2

u/procrastinationsboss 5d ago

how many unique items can it give?

i wonder if there's an easier way than /give for every item, like using dispensors and teleporting the resulting dropped item to the player

1

u/Over_Walk3859 5d ago

It can pick from a pool of 729 (9x9x9) unique items I pulled from the creative menu. I used dispensers placing shulker boxes for the randomization and then the giant mass of command blocks to determine which item to give.

Here are some other ways I thought of doing this, but decided not to because they'd be to tedious or inaccurate:

  1. Spawning the item at the player? - Nope, that's Java only.
  2. Saving the dropped item as a structure and loading it at the player? - I was worried about the pick up delay like if the player was stand over the edge as the item loaded in. Plus the command is much longer, especially if you have to write it over 700 times.
  3. Loading the structures outside the map and teleporting them to the player? - Might've worked, but what if two players were standing in the same spot? The one with pick up priority would get both. Plus there's the pick up delay concern again.

There might be some other way that I haven't thought of that would've been easier though.

1

u/procrastinationsboss 4d ago

does the current design work with multiple players online?

one idea i have for this kind of thing is have a field of armor stands, each holding an item

use /kill @r to kill 1 of them, /tellraw with the text selector to tell the player what item they got, then /tp the item to the player, then a structure block to reload all the armor stands - need to make sure it gets rid of the extra armor stands at some point

not sure exactly how i would make it handle having multiple players

1

u/Over_Walk3859 4d ago

What I did was I tagged each player with a specific tag, then made another tag to determine what player tag gets the item and cycle through the player tags with a scoreboard. In the video I gave myself all the player tags, so I got 4 items.

The downside of course is that the items aren't given at the same time, so player 1 with get their item around 5 seconds before player 4, but I don't know another way of solving that without rewriting all the give commands and then doing it another 3 times.

On top of that, I'm using /tickingarea to keep all the command blocks loaded, which causes some lag already. I think adding significantly more commands blocks to make it faster would only slow it down more instead.

I wish there was a way to save an item or something as a variable and reuse it in my commands blocks because otherwise I'd have to rewrite all the item names if I wanted to add anything.

1

u/procrastinationsboss 4d ago

with the armor stand thing, it would trade the lag of running 2200 command blocks with the lag of having 729 entities loaded

instead of /give, it would be teleporting items to the player, which might have some weird behavior

but using the selector json property means it can be fully done in like 10 or less command blocks

could make it a feature that ppl too close to each other dont get items

or abuse pickup priority lol

in my experience, entity lag starts aroung 1500+ entities, and gets real bad above 1800

but idk if that changes device to device, so not sure how it would compare to your chunk of command blocks

2

u/procrastinationsboss 3d ago

got it working with 121 armor stands for a test, theoretically works for multiple players but have only tested with one player
uses 6 commands to run the whole thing after it's set up

1

u/Over_Walk3859 10h ago

I see what you're talking about now, that's really cool! I didn't know @r targeted entities too, so I couldn't figure out how to make this work without using a big randomizer.

Is there a way to only allow one player to pick up an item, maybe with tags?

1

u/procrastinationsboss 5h ago

i can't think of any way to lock pickups to a specific player off the top of my head, but i'll do some research and see if there's something i'm missing

a different form of randomization that would work with a large command block solution such as yours would be the scoreboard randomization command, which could replace your shulker randomizer

1

u/ts_gamer23 4d ago

Respect, is it possible you could share the minigame world once it's done?

2

u/Over_Walk3859 4d ago

I wish. I make all sorts of minigames to play with my little brothers once and then never touch it again.

1

u/GlitteringPie4335 5d ago

Man you just unlocked some nostalgia for me I used to be a command creator

1

u/Time-Brain-7336 5d ago

Holy moly u are so creative and intellectual

1

u/Minecraft_creeper883 4d ago

Do you make mods?

1

u/TheLegoGod002011 4d ago

Thats cool.