Today I have been experimenting with issuing pre-written books using command blocks in Minecraft 1.8 on our #MolCraft Server. In version 1 of MolCraft we used replenishing chests which relied on a trapped chest activating a command block which used the ‘/clone’ command to copy a pre-filled chest from elsewhere in the map. (Thanks @Dragnoz). This technique works great on 1.8+ maps but we have an issue when we want to convert this to 1.7 maps because the ‘/clone’ command was introduced in 1.8!

So, why look for a 1.7 solution? Well, we want to convert our map to MinecraftEDU, which is currently still only 1.7.10… We need to make this work for 1.7.10!

After hunting for a mod solution to see if there was a way of making replenishing chests in 1.7.10 Forge, I thought around the problem and thought that using a simple ‘/give @p minecraft:item 1’ would suffice. So, when the player opens the trapped chest, or presses a button they are rewarded with the item… Pretty similar to a replenishing chest and the commands could be stacked to provide more than one item.

Easy enough for single items like a iron_shovel or golden_boots but what about our pre-written books? How do I give out a prewritten book to the player?

Again, I knew how to do this from past experience, but had trouble formatting the text in the book… the command to create a new line ‘\n’ was not working in any of my books.

So, I did a bit of digging about and found this really useful post by Skylinerw in the bugs section of the mojang site.

The command line for a 1 page book with line breaks is:

/give @p written_book 1 0 {title:"Title",author:"test",pages:["{text:\"Line 1\nLine 2\"}"]}

Thanks to SkylinerW on the Minecraftforum.net, we know the command line for multi-page book is:

/give @p written_book 1 0 {title:"Title",author:"test",pages:["Page 1","Page 2","Page 3","Etc."]}

These two snippets of code allow us to create books from command blocks without the need for a replenishing chest.

However, we need to do some tweaking to make this work for both 1.7 and 1.8 servers by combining both snippets in to one.

/give @p written_book 1 0 {title:"Amino Acid Quiz",author:"DrScients",pages:["{text:\"Line 1\nLine 2\"}","{text:\"Line 1\nLine 2\"}"]}

Title code in Blue author code in red Pages Array in green page 1 in orange page 2 in pink commas separate each part in black

It helps to write this out in code format to see how each part of the command works

/give @p written_book 1 0
    {
       title:"Amino Acid Quiz",
       author:"DrScients",
          pages:[
                  "{text:\"Line 1\nLine 2\"}",
                  "{text:\"Line 1\nLine 2\"}"
                 ]
    }

This means our map can now be translated to 1.7.10 and ported over to MinecraftEDU. Except for one thing… the formatting for a written book in 1.7 is different!!

We can use the TagString command to give out a book with multiple pages, the code below works fine in MinecraftEDU 1.7.10 build 20.

/give @p written_book 1 0 {title:"text",author:"text",pages:[TagString:"page 1 in here","page 2"]}

1.7.10 uses TagString to indicate written text in the code. However, adding in \n for line breaks does nothing and they are simply outputted in to the book as text.

My research tells me that this is a bug in the code that was fixed in the 1.8 update, however I would love to hear from anyone who has got written books with multiple pages and line breaks working in 1.7.10! (And I don’t mean by using line spaces to achieve the formatting!)

 

Hope this helps some others out there who might be looking for a similar solution.

Happy Crafting!

Share →

Leave a Reply

Clef two-factor authentication