Minecraft – Filling pages in a book without touching the other pages

minecraft-commandsminecraft-java-edition

Once again, I'm up to something advanced: In my map, I want to include a fast travelling system. Since the distance between warp points will likely be larger than the render distance (thus setting any blocks next to one warp point with a command launched at another loading point won't work because all out-of-render-distance blocks are "outside of the world"), I thought a book with JSON-formatted text that warps you around is most likely to work.

The problem is that, as in a typical fast travelling system, players shall only be able to warp to warp points they already visited. That means, when a player reaches a warp point, that player should be able to perform some action that adds in the JSON-formatted text in his/her book dynamically. That wouldn't be a problem, if it weren't for the existing text in the book…

I decided to dedicate a whole page for each warp point, mainly because I thought pages should be easier to keep separate. If someone has a solution that only works on a smaller scope for whatever reason, feel free to post that too. Basically, what I need to do is add new text (with click event) to a written book, without overwriting the text that's already there.

I know I could restrict where the players can go, so that I know in advance what text the book already has. That would be against the concept of the map though, because it's meant to be 100% nonlinear (which is why I want a fast travelling system in first place). The option to call different commands based on what content the book already has also came to my mind, but was quickly rejected because I would need to go through every possible combination of active and inactive pages, so the contraptions would grow exponentially with the number of warp points. Separate books for each warp point would be somewhat of an option, but it's only a last resort because it obviously takes up lots of inventory space.

I would prefer the solution to be compatible with 1.8, but if there's really no way without walking into above flaws, I can also resort to a later version. Mods are OK (preferably Forge compatible) as long as the map is playable in Vanilla afterwards.

Best Answer

You can not add pages. You can not add data to a specific element within the data tag with either of the data modifier commands.

A short quote from the dataTag section of both the blockdata and entitydata commands on the command wiki:

Specifies the data tag elements to be added to, or overwrite elements of

If you specify an element that is already in the data tag, it overwrites existing data.


You could use scoreboard tags as you can add/remove tags for each point in a nonlinear way without overwriting the existing tags.

The downside is having a book filled with clickEvents, some of which won't work until the player has the appropriate tag.