mojira.dev
MC-257788

give @s for written book doesn't work as intended

Long standing datapack of mine, when a player placed a cauldron, I give them a recipe book by an advancement executing a mcfunction.

// Some comments here
public String getFoo()
{
tellraw @s ["",{"text":"<Server> ","color":"white"},{"text":"Here is your one free copy of the Cauldron Cookin' recipe book.","color":"green"}]

give @s written_book{pages:["{\"text\":\"\\n\\nCauldron Cookin'\\n\\nby GatKong\\n\\n\\n\\nThe cauldron must have water in it and a fire under it to get it cooking.\"}","[\"\",{\"text\":\"Contents\",\"bold\":true},{\"text\":\"\\n\\n-\",\"color\":\"reset\"},{\"text\":\"Bottle Experience\",\"clickEvent\":{\"action\":\"change_page\",\"value\":3}},{\"text\":\"\\n-\"},{\"text\":\"Freshen Flesh\",\"clickEvent\":{\"action\":\"change_page\",\"value\":4}},{\"text\":\"\\n-\"},{\"text\":\"Identify Stew\",\"clickEvent\":{\"action\":\"change_page\",\"value\":5}},{\"text\":\"\\n-\"},{\"text\":\"Rice Krispy Treats\",\"clickEvent\":{\"action\":\"change_page\",\"value\":6}},{\"text\":\"\\n-\"},{\"text\":\"Snag Enchantment\",\"clickEvent\":{\"action\":\"change_page\",\"value\":7}},{\"text\":\"\\n-\"},{\"text\":\"Spawn Egg\",\"clickEvent\":{\"action\":\"change_page\",\"value\":8}},{\"text\":\"\\n-\"},{\"text\":\"Summon Player\",\"clickEvent\":{\"action\":\"change_page\",\"value\":9}},{\"text\":\"\\n-\"},{\"text\":\"Summon Killer Hare\",\"clickEvent\":{\"action\":\"change_page\",\"value\":10}},{\"text\":\"\\n-\"},{\"text\":\"Summon Rain\",\"clickEvent\":{\"action\":\"change_page\",\"value\":11}}]","[\"\",{\"text\":\"Bottle Experience\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\nbottle o' enchanting\\noxeye daisy\\nsugar\\nblaze powder\\n\\nMakes one Potion of Experience containing 100 experience if you have it, or one Bottle o' Enchanting if you don't.\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Freshen Rotten Flesh\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\npotion of regeneration\\nblock of coal\\nblue orchid\\nrotten flesh\\n\\nMakes one batch up to a stack.\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Identify Suspicious Stew\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\nsuspicious stew\\nsunflower\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Rice Krispy Treats\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\nMelt the butter in a cauldron on medium heat. Add 6 cups Mini Marshmallows, stir until they are completely melted. Add 6 cups of Rice Krispie Cereal and mix. Spoon into a 9×11\\\" pan.\\n\\nAllow to cool.\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Snag Enchantment\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\nbottle o' enchanting\\nbook\\nenchanted item\\nfermented spider eye\\n\\nFull cauldron: extracts all the enchantments from the item.\\n\\nPartial: extracts one enchantment.\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Spawn Egg\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\nmundane potion\\nspawner\\nbone meal\\nspecial ingredient\\n\\nLastly, hold an egg over the cauldron.\\n\\nMakes one spawn egg, type depending on the special ingredient.\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Summon Player\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\npotion of swiftness\\ngolden boots\\nfeather\\nbeetroot seeds\\n\\nThe summoned must be holding a beetroot.\\n\\nDon't hate the player, hate the braam.\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Rabbit of Caerbannog\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\npotion of harming\\nnether wart\\nredstone dust\\none live rabbit\",\"color\":\"reset\"}]","[\"\",{\"text\":\"Summon Rain\",\"color\":\"dark_purple\"},{\"text\":\"\\n\\nwater breathing ptn\\nlily pad\\nwater bucket\\nredstone dust\",\"color\":\"reset\"}]"],title:"Cauldron Cookin'",author:"Margery Moragan",display:{Lore:['{"text":"A cauldron recipe book"}']}}

}

Lately, the player gets the tellraw @s message that they are being given a book, verifying the command is being executed as the intended player, but they don't get the book. The book is dropped at the execution location (in this case the default being the world spawn).

I was able to get around this by changing the command to be:
execute at @s run give @s...

Attachments

Comments 4

The format you provided is not a valid data pack format, but rather, java code. Please provide an actual vanilla setup to test this in an unmodded game. Additionally, verify it's not another command moving the item entity.

Please attach the entire pack, or at least a pack with at least the minimal files required to reproduce your issue

To followup...
@Dhranios there are no mods, running vanilla with datapacks. No java code.

@[Mod] tryashtar See attached datapack as requested

[media]

. After extensive trouble shooting and testing, I've determined the give @s written_book command works as intended in single player (both alone and with many other datapacks running) and in multiplayer when running this datapack alone. The scenario wherein the give command fails to give at the @s target occurs when the server is running multiple other datapacks, even though server logs show no indication the server can't keep up (in the attached, I've included the server's latest.log during which the datapack's give written_book command fails so you can see, while the log has many things to say, none of the logs pertain to the datapack in question nor indicate any difficulty in the server keeping up). Considering it's still vanilla Minecraft, other datapacks running concurrently still shouldn't cause the give command to fail as it does. To experience the exact scenario wherein the give command is failing, you may join my open server at gapple.mchost.pro, and try placing a cauldron for the first time. It should give you a written book. It gives the book at spawn instead.

If the attached pack can't be used to reproduce the issue, I'm afraid it's not useful and we will need something that can

Gatinh0

(Unassigned)

Unconfirmed

(Unassigned)

1.19.2

Retrieved