Last active
November 13, 2017 10:42
-
-
Save tryashtar/a227d6ec921f4aaf2784b3033c82792b to your computer and use it in GitHub Desktop.
Commands used to generate RGB values for armor, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fake players beginning with '#' are literal values, the rest are as follows: | |
# h: color hue, between 0 and 1536 | |
# r: red color component | |
# g: green color component | |
# b: blue color component | |
# speed: speed of the color change, in hue increments per tick | |
# temp: used for a temporary calculation | |
# rgb: the final number representing the rgb in its entirety | |
# move on to the next hue | |
scoreboard players operation h color += speed color | |
execute if score h color > #1536 color run scoreboard players set r color 255 | |
execute if score h color > #1536 color run scoreboard players set g color 0 | |
execute if score h color > #1536 color run scoreboard players set b color 0 | |
execute if score h color > #1536 color run scoreboard players set h color 0 | |
# change r, g, or b depending on where the hue is | |
execute if score h color < #256 color run scoreboard players operation g color += speed color | |
execute if score h color > #256 color if score h color < #512 color run scoreboard players operation r color -= speed color | |
execute if score h color > #512 color if score h color < #768 color run scoreboard players operation b color += speed color | |
execute if score h color > #768 color if score h color < #1024 color run scoreboard players operation g color -= speed color | |
execute if score h color > #1024 color if score h color < #1280 color run scoreboard players operation r color += speed color | |
execute if score h color > #1280 color if score h color < #1536 color run scoreboard players operation b color -= speed color | |
# some sanity checks to prevent r, g, and b from going too high or too low | |
execute if score r color < #0 color run scoreboard players set r color 0 | |
execute if score g color < #0 color run scoreboard players set g color 0 | |
execute if score b color < #0 color run scoreboard players set b color 0 | |
execute if score r color >= #256 color run scoreboard players set r color 255 | |
execute if score g color >= #256 color run scoreboard players set g color 255 | |
execute if score b color >= #256 color run scoreboard players set b color 255 | |
# "shift" r and g properly and add everything to rgb | |
scoreboard players operation rgb color = r color | |
scoreboard players operation rgb color *= #256 color | |
scoreboard players operation rgb color *= #256 color | |
scoreboard players operation temp color = g color | |
scoreboard players operation temp color *= #256 color | |
scoreboard players operation rgb color += temp color | |
scoreboard players operation rgb color += b color | |
# example of putting rgb into an item | |
execute store result entity @e[type=item_frame,sort=nearest,limit=1] Item.tag.CustomPotionColor int 1 run scoreboard players get rgb color |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment