Code of Copper Extensions
This extension pack adds several useful functions to Code of Copper, primarily intended for use in creative mode or by server operators.
Although developed by one of the creators of Code of Copper, this pack is unofficial. Some of the functions presented here may be incorporated into the main version in the future, but most will remain exclusive to this add-on.
Requirements
- Only works in Minecraft versions 1.20.2 and above
- Requires Code of Copper to be installed
Available Functions
Exec
Allows executing any commands passed as strings. Commands are executed by the bot at its current location. Supports multiple strings in a single function.
exec("time set day") # Sets time to day
exec("weather clear", "gamemode adventure @p") # Sets clear weather and adventure mode for the nearest player
Tp
Teleports the selected entity to the specified coordinates. Coordinates can be integers or strings. By default, teleports the bot itself (@s). The tilde symbol ~ indicates relative coordinates from the bot's position.
tp(0, 64, 0) # Teleports the bot (@s) to coordinates 0, 64, 0
tp(0, 64, 0, "@a") # Teleports all players (@a) to coordinates 0, 64, 0
tp("~", "~8", "~", "@p") # Teleports the nearest player 8 blocks above the bot
tp("~", 100, "~", "@p") # Teleports the nearest player to height 100 above the bot
Setblock
Alternative to the place() function, doesn't require blocks in inventory. Coordinates can be integers or strings. The tilde symbol ~ indicates relative coordinates from the bot's position.
setblock(:stone, 0, 64, 0) # Places minecraft:stone block at coordinates 0, 64, 0
setblock(:grass_block, "~", "~8", "~") # Places minecraft:grass_block block 8 blocks above the bot
Score
Returns the score of the selected entity as an integer. By default uses the nearest player (@p).
score("myscoreboard") # Returns the score of @p for scoreboard myscoreboard
score("myotherscoreboard", "Moxvallix") # Returns the score of Moxvallix for scoreboard myotherscoreboard
Scoreset
Sets the score of the selected entity from a given integer. By default uses the nearest player (@p). Returns the set value.
scoreset("myscoreboard", 8) # Sets @p's score to 8 for scoreboard myscoreboard
scoreset("myotherscoreboard", 123, "Gears_YT") # Sets Gears_YT's score to 123 for scoreboard myotherscoreboard
Rule
Returns the value of a game rule as an integer. If a second argument is specified, sets the game rule to that value. Accepts strings, integers, or boolean values as the second argument.
rule("keepInventory") # Returns the value of keepInventory rule (0 if false, 1 if true)
rule("doFireTick", false) # Sets doFireTick rule to false, returns 0
rule("randomTickSpeed", 5) # Sets randomTickSpeed rule to 5, returns 5
Run
Executes the specified function as a resource and returns the value that the function returns.
run(:foo) # Executes minecraft:foo function, returning its result
run(code:bar) # Executes code:bar function, returning its result