Skip to content

Instantly share code, notes, and snippets.

@tryashtar
Created April 26, 2026 16:49
Show Gist options
  • Select an option

  • Save tryashtar/4247adce582a26d25495a684a835e148 to your computer and use it in GitHub Desktop.

Select an option

Save tryashtar/4247adce582a26d25495a684a835e148 to your computer and use it in GitHub Desktop.
Function to shuffle a player's hotbar
scoreboard objectives add shuffle dummy
summon item_display ~ ~ ~ {UUID:[I;1893057366,1621903990,-1122899821,562243024]}
execute store result score temp shuffle run random value 0..8
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.8
execute if score temp shuffle matches 0 run item replace entity @s hotbar.8 from entity @s hotbar.0
execute if score temp shuffle matches 1 run item replace entity @s hotbar.8 from entity @s hotbar.1
execute if score temp shuffle matches 2 run item replace entity @s hotbar.8 from entity @s hotbar.2
execute if score temp shuffle matches 3 run item replace entity @s hotbar.8 from entity @s hotbar.3
execute if score temp shuffle matches 4 run item replace entity @s hotbar.8 from entity @s hotbar.4
execute if score temp shuffle matches 5 run item replace entity @s hotbar.8 from entity @s hotbar.5
execute if score temp shuffle matches 6 run item replace entity @s hotbar.8 from entity @s hotbar.6
execute if score temp shuffle matches 7 run item replace entity @s hotbar.8 from entity @s hotbar.7
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 1 run item replace entity @s hotbar.1 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 2 run item replace entity @s hotbar.2 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 3 run item replace entity @s hotbar.3 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 4 run item replace entity @s hotbar.4 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 5 run item replace entity @s hotbar.5 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 6 run item replace entity @s hotbar.6 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 7 run item replace entity @s hotbar.7 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute store result score temp shuffle run random value 0..7
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.7
execute if score temp shuffle matches 0 run item replace entity @s hotbar.7 from entity @s hotbar.0
execute if score temp shuffle matches 1 run item replace entity @s hotbar.7 from entity @s hotbar.1
execute if score temp shuffle matches 2 run item replace entity @s hotbar.7 from entity @s hotbar.2
execute if score temp shuffle matches 3 run item replace entity @s hotbar.7 from entity @s hotbar.3
execute if score temp shuffle matches 4 run item replace entity @s hotbar.7 from entity @s hotbar.4
execute if score temp shuffle matches 5 run item replace entity @s hotbar.7 from entity @s hotbar.5
execute if score temp shuffle matches 6 run item replace entity @s hotbar.7 from entity @s hotbar.6
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 1 run item replace entity @s hotbar.1 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 2 run item replace entity @s hotbar.2 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 3 run item replace entity @s hotbar.3 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 4 run item replace entity @s hotbar.4 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 5 run item replace entity @s hotbar.5 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 6 run item replace entity @s hotbar.6 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute store result score temp shuffle run random value 0..6
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.6
execute if score temp shuffle matches 0 run item replace entity @s hotbar.6 from entity @s hotbar.0
execute if score temp shuffle matches 1 run item replace entity @s hotbar.6 from entity @s hotbar.1
execute if score temp shuffle matches 2 run item replace entity @s hotbar.6 from entity @s hotbar.2
execute if score temp shuffle matches 3 run item replace entity @s hotbar.6 from entity @s hotbar.3
execute if score temp shuffle matches 4 run item replace entity @s hotbar.6 from entity @s hotbar.4
execute if score temp shuffle matches 5 run item replace entity @s hotbar.6 from entity @s hotbar.5
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 1 run item replace entity @s hotbar.1 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 2 run item replace entity @s hotbar.2 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 3 run item replace entity @s hotbar.3 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 4 run item replace entity @s hotbar.4 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 5 run item replace entity @s hotbar.5 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute store result score temp shuffle run random value 0..5
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.5
execute if score temp shuffle matches 0 run item replace entity @s hotbar.5 from entity @s hotbar.0
execute if score temp shuffle matches 1 run item replace entity @s hotbar.5 from entity @s hotbar.1
execute if score temp shuffle matches 2 run item replace entity @s hotbar.5 from entity @s hotbar.2
execute if score temp shuffle matches 3 run item replace entity @s hotbar.5 from entity @s hotbar.3
execute if score temp shuffle matches 4 run item replace entity @s hotbar.5 from entity @s hotbar.4
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 1 run item replace entity @s hotbar.1 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 2 run item replace entity @s hotbar.2 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 3 run item replace entity @s hotbar.3 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 4 run item replace entity @s hotbar.4 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute store result score temp shuffle run random value 0..4
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.4
execute if score temp shuffle matches 0 run item replace entity @s hotbar.4 from entity @s hotbar.0
execute if score temp shuffle matches 1 run item replace entity @s hotbar.4 from entity @s hotbar.1
execute if score temp shuffle matches 2 run item replace entity @s hotbar.4 from entity @s hotbar.2
execute if score temp shuffle matches 3 run item replace entity @s hotbar.4 from entity @s hotbar.3
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 1 run item replace entity @s hotbar.1 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 2 run item replace entity @s hotbar.2 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 3 run item replace entity @s hotbar.3 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute store result score temp shuffle run random value 0..3
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.3
execute if score temp shuffle matches 0 run item replace entity @s hotbar.3 from entity @s hotbar.0
execute if score temp shuffle matches 1 run item replace entity @s hotbar.3 from entity @s hotbar.1
execute if score temp shuffle matches 2 run item replace entity @s hotbar.3 from entity @s hotbar.2
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 1 run item replace entity @s hotbar.1 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 2 run item replace entity @s hotbar.2 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute store result score temp shuffle run random value 0..2
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.2
execute if score temp shuffle matches 0 run item replace entity @s hotbar.2 from entity @s hotbar.0
execute if score temp shuffle matches 1 run item replace entity @s hotbar.2 from entity @s hotbar.1
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute if score temp shuffle matches 1 run item replace entity @s hotbar.1 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
execute store result score temp shuffle run random value 0..1
item replace entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents from entity @s hotbar.1
execute if score temp shuffle matches 0 run item replace entity @s hotbar.1 from entity @s hotbar.0
execute if score temp shuffle matches 0 run item replace entity @s hotbar.0 from entity 70d5c356-60ac-4a76-bd11-e893218325d0 contents
kill 70d5c356-60ac-4a76-bd11-e893218325d0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment