Disclaimer
The section symbol is deprecated. You should avoid using it as much as possible and be aware that it will not work in the future. It is being replaced by the JSON text component, which is already supported by chat (accessible with /tellraw
), book pages, sign text, and the /title
command.
In-game with signs
Because sign text supports the text component, it also supports unicode characters (declared as \u####
). The character for the section symbol is \u00A7
.
You would use the sign to run a clickEvent that provides you with a command block that uses the section symbol at the appropriate location in its syntax. You'd then place the command block where needed.
Note that this will only work for signs because it's the sign running the command, rather than the player being forced the run the command in the chat like with /tellraw
or book pages. The player would otherwise be kicked for trying to type the section symbol.
Example command:
/setblock ~ ~1 ~ minecraft:standing_sign 0 replace {Text1:"[\"\"]",Text2:"[\"\"]",Text3:"[\"\"]",Text4:"{\"text\":\"Click\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/give @p minecraft:command_block 1 0 {BlockEntityTag:{Command:/summon Item ~ ~1 ~ {Item:{id:\\\"minecraft:stone\\\",Count:1b,tag:{display:{Name:\\\"\u00A71Custom Name\\\"}}}}}}\"}}"}
Using loot tables
A custom loot table can be created to provide you with a command block containing the section symbol, which can be pasted into the JSON file directly.
For example, the following would provide the necessary command block that you'd place where desired:
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"name": "minecraft:command_block",
"weight": 1,
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{BlockEntityTag:{Command:/summon Item ~ ~1 ~ {Item:{id:\"minecraft:stone\",Count:1b,tag:{display:{Name:\"ยง1Custom Name\"}}}}}}"
}
]
}
]
}
]
}
The command to place the chest containing the command block (assuming filepath world_name/data/loot_tables/custom/cmd.json
):
/setblock ~ ~1 ~ minecraft:chest 0 replace {LootTable:"custom:cmd"}
You can modify the command block that contains the /summon
command using either of these programs to contain the section symbol at the desired spot in its syntax.
Using MCEdit, you'd locate the command block, double-click it, and paste the section symbol and color code within the command itself.
With NBTExplorer, you would need to locate the command block first by copy/pasting into the program's Search tool. You would then double-click the Command
value and paste the section symbol at the appropriate location.
Solution: Saving the current music progress in a scoreboard.
This example assumes a loop length of 42 seconds, just to have a value. A score value of 0 makes the music start, everything from 1 to 839 prevents the sound from being played and 840 means that the player is ready to hear the music again.
First, do this:
/scoreboard objectives add music dummy
Then put these commands in your game loop:
/execute as @e[type=Zombie] at @s run scoreboard players set @a[distance=..10,scores={music=840..}] music 0
/execute as @e[type=Skeleton] at @s run scoreboard players set @a[distance=..10,scores={music=840..}] music 0
/execute as @e[type=Creeper] at @s run scoreboard players set @a[distance=..10,scores={music=840..}] music 0
/playsound someTunes hostile @a[scores={music=0}]
/scoreboard players add @a[scores={music=..839}] music 1
First you reset the ticking "music" score of every player who is near a mob, but only if it has already ticked up to 42 seconds for him.
Then you play the music to every player who just got their score reset.
Then you tick the score up.
Here (archive) is a list of all entity IDs, to help you not forget some of them.
Best Answer
The facing of a chest is determined by it's block data value, ranging from 2 to 5 (North, South, West, East). For Falling Sand Entities the data value of the block can be set by adding a
Data
tag to the entity:(I also replaced
TileID
with the newerBlock
. This doesn't exactly matter, but numerical IDs are being phased out gradually, and I expectTileID
to break in the future.)However, as pointed out by MBraedley in the comments, summoning a chest with items can be done directly via
setblock
, rather than using the old roundabout way of summoning falling sand.The syntax is
Here, the data value can be set directly. To set the data tag, you'll need to specify
oldBlockHandling
, I suggest using the default value ofreplace
:This command is not only shorter and easier to read, it also executes much faster than the summon version. That is because it doesn't need to create an entity, have it drop to the floor, determine collision, and then turn it into a block and remove the entity.