Since discovering that you can play Minecraft on your phone, one thing has been bothering me. You can take flour, eggs, milk, and sugar to make a cake, or flour and cocoa beans to make chocolate chip cookies, or even pumpkin, egg, and sugar to make a pumpkin pie, and yet despite having a perpetual surfeit of carrots, there is no way for me to craft a carrot cake - the best cake that there is.
Delightfully, even though this is a phone app, there are various ways to add your own items and patches. On Android, I used BlockLauncher Pro (£2.54, or the identical free version, which has ads). This allows you to add custom texture packs and little scripts in ModPE. It was difficult to find a comprehensive tutorial or documentation, so I used other people's scripts, this useful function list, and trial and error to work out how to create my cake.
I started by making an icon for the cake. It needs to be a 16 x 16 PNG.
This is the image that will be shown in the inventory, and will be held in the player's hand.
To tell Minecraft PE to use it, you need to zip it up in the correct folder structure. The path to the image is 'images/items-opaque/carrot_cake_0.png'. In the root of the folder is a meta-data file called 'pack.mcmeta'. This contains the description of your image pack:
{ "pack": { "pack_format": 1, "description": "Carrot cake!" } }
I put these all together into Carrot Cake Texture.zip. To install this, download the file, then open up BlockLauncher and click on the spanner at the top of the screen. Then go to 'Texture Pack', 'Select', and pick the file out of your Downloads folder. This step doesn't do anything particularly exciting, but it comes into its own when we add some javascript.
In a new file, called 'carrot_cake.js', we can define the new item.
ModPE.setFoodItem(501,"carrot_cake","carrot_cake",6,"Carrot Cake");
ModPE.setFoodItem is the command to add a new edible object. Each item in Minecraft has a unique ID. I picked 501 for the carrot cake, because it hasn't been used yet. "carrot_cake" is the name of the picture to use from the texture pack - this is defined by taking 'carrot_cake_0.png' and removing '_0.png'. 6 is the number of half hunger points you gain by eating the carrot cake. Finally we define the name that is shown to the user, 'Carrot Cake'.
Next, we want to make the cake available in the inventory in Creative Mode, by using its ID of 501:
Player.addItemCreativeInv(501,1,0);
Next, I wanted to be able to make a cake out of carrots, wheat, egg, and sugar. You can look up the item IDs of items in Minecraft to do this step. Carrot is 391, sugar is 353, egg is 344, and wheat is 296.
Item.addCraftRecipe(501, 1, 0, [391, 2, 0, 353, 1, 0, 344, 1, 0, 296, 1, 0]);
To use this, download carrot_cake.js and open up BlockLauncher, then click on the spanner and go to 'Manage ModPE Scripts'. Press 'import' and find the file in your Downloads folder. Now if you go back to the main menu and open up your game, you should be able to make yourself a lovely cake!
Here's some new mods for Minecraft Pocket Edition you want to play.