How To Edit Bad Piggies Levels & Get A Larger Building Grid (Editing The Source Code)
Sep 24, 2014MobileComments (54)
This is a lengthy and technical post about editing the Bad Piggies application code in order to edit levels, enlarge the building grid, and make other tweaks to the gameplay. This covers the Windows and Android versions only, but the process will be similar for Mac and iOS if you can get access to the game application files.

Note: This guide currently only works with version 1.6.0 and earlier.

First, here is a screenshot showing what you can accomplish with these edits. This is the Fields Of Dreams level (on Android) with a larger building grid and nearly unlimited items:

Bad Piggies Larger 13x8 Building Grid
Click to see the video



Disclaimer


Following this guide could lead to breaking your game and losing your progress. Continue at your own risk. I will not provide pre-modded files; you'll have to edit your own files by following this guide.


Requirements


Here is what you'll need to get started:
 - A good text-editor with UTF-8 support like Notepad++

To edit the Windows version:
 - The PC version of the game installed (that's it!)

To edit the Android version:
 - The APK for the game, which you can get at an online APK mirror
 - A basic file browser
 - An archiver like 7-Zip to open the APK file


Basic Information


Bad Piggies is made with the Unity game engine and utilizes numerous assets files to control the game. These files usually have the extension .assets, but not always.

You can edit assets files directly using a good text editor. There are tons of different assets files and most contain what looks like a massive pile of gibberish characters. Hidden among this gibberish are little blocks of code that are human-readable, and which contain variables that affect the gameplay.

File Size
While editing assets files, they must always end up the same file size that they were originally. This is to pass a file size validity check that the game performs. Always make a backup of the assets file before editing and make a note of its Size in bytes. For example, if you change "count = 5" to "count = 150", you've added two characters, increasing the file size by two bytes, and so must remove two characters elsewhere to offset this. Addition and removal of characters must be done within the same parent GameObject.

Whitespace
The assets files are strictly-typed and whitespace matters. You must preserve tabs, newlines, and whitespace or you may run into errors. These files also use \r\n (carriage return & line feed) for every line break, which is the Windows standard. That's two characters per line break. It may seem counter-intuitive that a line break is two characters and not one. Read more about that here.

Level Editing
This guide will show you how to edit the Field Of Dreams level (seen in the screenshot above), which is called Sandbox_06 internally by the game. View the Level Number Cross Reference at the bottom of this post to find out the internal names for each of the other sandbox levels. You can use what you learn in this guide to edit any of the other levels in the game.

Base Zero Numbering
Everything uses base-zero numbering. So if you have an array containing 3 elements, the elements will be numbered 0, 1, and 2. Learn more about base-zero here.


Assets File


The assets file you need to edit is in a different location on each platform.

PC/Windows
The assets file that you want to edit is called resources.assets and resides in the data folder of your Bad Piggies PC installation.

Bad Piggies Resources.Assets

Open it in your text editor. Keep in mind that it may run slow; it has over 300,000 lines of code. This large assets file contains numerous levels. To get to the Field Of Dreams level, search for the first occurrence of "Level_Sandbox_06_data".

Android
Open up the APK with 7-Zip. You'll see this:

Bad Piggies APK 7-Zip

Go into the assets folder, then bin, then Data. In there are hundreds of files, some without extensions. The file that contains the Field Of Dreams level is called 746ee37fafe29a34ba3f2032ea011e0a (no extension). Extract just that file out and open it in your text editor.


Editing The Assets File


Now that you have the correct assets file for your platform, it's time to make the revisions. Scroll down until you are looking at data that looks like this (starting with GameObject):

Bad Piggies Resources.Assets Notepad++


Step 1: Zooming Out
The first thing we need to do is adjust the default zoom level when building. If you don't do this, you won't be able to see the whole build grid once we increase it.

Go down about 33 lines and you'll find Array m_controlPoints. This controls the points that the camera pans and zooms to when you first start a level. It contains 8 elements (Element 0 through Element 7). The final element (7) is also the position of the camera during building. Its default zoom level is "Float zoom = 5.5". Change that to "Float zoom = 6.0". This will allow for more visible area for a larger build grid. It will look like this when you're done:

Bad Piggies Resources.Assets Notepad++

Note: Since we only changed "5.5" to "6.0", we didn't change the total number of characters or file size of the assets file.


Step 2: Larger Build Grid
To increase the build grid size, we need to modify the Array m_constructionGridRows. Go down about 47 lines from the zoom change you did above and you'll find it.

The Array m_constructionGridRows contains multiple Elements. Each Element corresponds to a row in the building grid. Its size (how many Elements it can contain) is specified by ArraySize size. By default it is set to 7. This means that there can be up to 7 rows in the building grid.

Now the curious thing about the Field Of Dreams level is that it only lists Element 6 (the last element) and none of the ones before it (0 through 5):

Bad Piggies Resources.Assets Grid 1

If an element is not listed it defaults to 10 boxes in the row. So that means Elements 0 through 5 (not listed) default to 10. That's 6 rows of 10 boxes each, which is correct (you can confirm this by playing the Field Of Dreams level). The final seventh element that is listed has its data set to 0, which means nothing in that row.

We want to add additional building rows as well as make each row contain more boxes, so we have to manually add in the missing Elements. This gets a little tricky but isn't too hard. Change the ArraySize to 8 (for 8 rows) and then copy and paste the Element 6 seven times until you end up with this:

Bad Piggies Resources.Assets Grid 2

Make sure you retain the same tab, space, and line breaks used in the file.

Now edit each of them to put them in sequence and change the data attribute to 8191 (not 0). Why 8191? I'll explain in a moment. Here is what you should end up with:

Bad Piggies Resources.Assets Grid 3

You now have 8 building rows, each with the value 8191, which means each row will have 13 build boxes. The reason 8191 means 13 is because the game uses the formula boxes = 2^n - 1 on the value (n) to determine the number of boxes in the row. If you just wanted 10 boxes per row (the default max), you would use 1023. Please look at this chart to get an idea why:

0 = 2^0 - 1
1 = 2^1 - 1
3 = 2^2 - 1
7 = 2^3 - 1
15 = 2^4 - 1
31 = 2^5 - 1
63 = 2^6 - 1
127 = 2^7 - 1
255 = 2^8 - 1
511 = 2^9 - 1
1023 = 2^10 - 1
2047 = 2^11 - 1
4095 = 2^12 - 1
8191 = 2^13 - 1
16383 = 2^14 - 1
32767 = 2^15 - 1
65535 = 2^16 - 1

It might be confusing, but just know that 8191 means you'll get 13 boxes per build row. You can change it to something else, but just stick with it for now until you fully understand it.


Step 3: Unlimited Build Items
Now that you have the build grid done, you want to increase the number of items available to build with. This is done directly underneath in Array m_partTypeCounts. You'll see 43 Elements, each with an Integer count value. Increase all of these counts to something like 50 (or higher if you want). It will look like this:

Bad Piggies Resources.Assets Grid 4


Step 4: Fixing The File Size
So now that we've added a bunch of characters to the assets file, we need to remove an equal number of characters to bring the file size back to the original. This will largely be guess and check. Many of the variables in this GameObject are optional and can be deleted to reduce bytes. For example, these lines can be deleted entirely:

Float m_previewZoomOut = 8
Float m_previewMoveTime = 4
Float m_previewWaitTime = 1
Integer m_DessertsCount = 40
Boolean m_SuperBluePrintsAllowed = False

You can also delete these lines further down:

Integer m_tutorialBookPage = 65
ObjectReference m_tutorialBookPagePrefab = 4

You can then adjust some of the float numbers to fine tune the file size. For example, you can add zeros to the end of a float (decimal) without changing what it means.

Just keep working with it until you've got the file size back to the original amount. Be careful not to delete any spaces or tabs (whitespace) in front of variables that you want to keep.

Once you're done, open up the game and try it out! If it gives you an error, you may have accidentally deleted something important, or the file size may be different. Double-check that the size is the same (not size on disk, but the actual size in bytes).


Using Your Modified Version


If you're on PC, you should be done now and able to open the game (you can actually edit the assets files while the game is running). If you're on Android you have a few more steps depending on your version of Android:

Android 4.4 and Earlier
Copy the edited 746ee37fafe29a34ba3f2032ea011e0a file back into the APK (using 7-Zip). And then copy the modified APK file over to the Android and overwrite your original Bad Piggies APK file. Keep a backup of the original before overwriting it and a backup of the modified APK on your PC, in case you need to reinstall.

Android 5.0 and Later (ART runtime)
Since the new runtime in Android precompiles applications, you have to install your modified base.apk (you can't just overwrite the old one). It's not too complicated. After you've copied the edited 746ee37fafe29a34ba3f2032ea011e0a file back into the APK (using 7-Zip), follow these steps:

1. Make a backup of your save files, which is the folder named files in Android/data/com.rovio.BadPiggiesHD/. Copy the files folder to a safe location (maybe keep a backup on your PC).

2. Uninstall Bad Piggies from your device, and delete the folder Android/data/com.rovio.BadPiggiesHD completely.

3. Now copy your modified base.apk file over to your device, using your File Manager, somewhere easy to access like your downloads folder.

4. Install Zip Signer from the Google Play Store and open it. Hit the "Choose In/Out..." button and navigate to the base.apk. Then hit "Sign The File". The app will take a few moments and then generate a new APK that is signed.

5. If you haven't yet, you'll need to allow installations from unknown sources. Enable the option at Settings > Security > Unknown Sources.

6. Navigate to your signed APK using your File Manager and tap it to install it. Once done, you will now have the installed Bad Piggies with your modifications. Do not use the Play store to update Bad Piggies or it may overwrite your edits.


Sandbox Level Number Cross Reference


Sandbox_01 = Find The Skulls
Sandbox_02 = Ground Hog Day 2
Sandbox_03 = When Pigs Fly 1
Sandbox_04 = Ground Hog Day 1
Sandbox_05 = When Pigs Fly 2
Sandbox_06 = Field Of Dreams
Sandbox_07 = Flight In The Night 1
Sandbox_08 = Flight In The Night 2
Sandbox_09 = Rise And Swine 1
Sandbox_10 = Rise And Swine 2

If you're on Android it can be difficult to find out which of the hundreds of files contains the sandbox level you want to edit. I recommend using the Find in Files functionality of Notepad++.
Comments (54)
Add a Comment
SeptionGD   Jun 21, 2024
Man, I remember this. This article aged very well
Piggies   Jun 04, 2023
Edit: you can delete the words “Generic data” for all objects (don’t delete the whole lines)
GDPlayer56749   Mar 08, 2023
@Windows Vista User 198323 Yes, it works on any operating system the game supports (I believe it supports all the way down to Windows XP and up to Windows 11) And it does work on version 1.3.0.
poop   Jan 27, 2023
i think my version has encrypted that file or smth to avoid modding cuz all i see is a bunch of symbols
Mighty Eagle   Mar 09, 2022
For those of you who want to edit the Little Pig Adventure level (on android) the correct file is a7dbf74284b954c518fc1065a10d92c8
Windows Vista User 198323   Dec 24, 2021
Does This Work In Bad Piggies 1.3.0 on Microsoft Windows 10? Also, Does This Work On Microsoft Windows Vista Software?
mnz 173   Nov 12, 2021
how can I download this mod?
Alvi798   Oct 11, 2021
So this only works with version 1.6.0 or older. If the screen goes black while opening the game it means the has mismatched and you need to keep the file size same as before to open the game again.If the file size is matched the game will open normally.
BadPigs :)   Aug 09, 2021
For those of you trying to edit little pig adventure the assets file is a7dbf74284b954c518fc1065a10d92c8 (for Android only)
Piggies   Jul 27, 2021
Thank you for this article, Nick. I was able to edit Field of Dreams and get the game running. (I was able to do this hack for both android and PC) I have useful information for those of you having trouble getting the game to work: 1. To keep track of an equal amount of characters, look at the length bar at the bottom of Notepad++. 2. You can delete the Generic data lines below all of the elements to reduce the file size. 3. You can change Boolean m_sandbox to true if you want a specific amount of each item (since the number of items add up as you play more levels) 4. Zip Signer has currently been removed from Play Store. Instead, install apk signer to sign the apk.
angry pigs   Jun 07, 2021
I am using v1.3.0 and I was able to get more items but I couldn't extend the grid. And also, you can delete the Generic data lines for all of the objects.
carlos   Apr 01, 2021
I did everything the same and it does not work for me, when I start the game the screen remains black, I use version 1.3.0 in windows 10
Guy McGuy   Feb 04, 2021
Screen goes black after opening
Wdaw   Jan 13, 2021
ohh element 35: egg
Wdaw   Jan 12, 2021
Identification of all element types in 1.5.1 excluding Element 35: 0:pig 1-3: balloons 4: fan 05: wooden box 07: wooden wheel 8:null 09-11: sack of rocks (simple/double/triple) 12: helicopter small 13: wooden wing 14: wooden tail 15: diesel-powered engine -2 16: blue rocket 17: metal box -3 18: tiny wheel -1 19: metal wing 20: metal tail 21: helicopter 22: wheel selfpropelled 23: TNT 24: fan engine -2 25: V8 engine 26: wheel 27: spring -1 28: umbrella 30:black cola 31: king pig 32: red rocket 33: green cola 34: yellow umbrella 35: idk 36: n/a 37:n/a 38:boxing machine 39:stickywheel 40:sticky gun 41:candies 42:decoupler. NOTE: you can delete generic data lines in Element 36 and Element 37. N/A elements are missing...
Somebody   Jan 10, 2021
How do u do this
Somebody   Jan 10, 2021
How do u do this
Wdaw   Jan 08, 2021
The grid limit is 2147483647 and there is no limit of height...
BadPiggies Hacker   Dec 15, 2020
I am using BP 1.3
BadPiggies Hacker   Dec 14, 2020
I have a suggestion: Remove the x y z coordinate's point and the numbers to reduce the file size
Kikijs221   Oct 08, 2020
can u di an update cant find 746ee37fafe29a34ba3f2032ea011e0a pretty sure it has been changed
cloy   Sep 29, 2020
And can you show how to actually unlock field of dreams?
cloy   Sep 29, 2020
Hi, could you show how to add 9999 of boosts and glue and stuff like that?
Dolan 295   Jul 07, 2020
I CAN'T GET IT!
I had nothing   May 08, 2020
Can you tell us how to add more ora edit the amount on the items in Bad Piggies
hemoridhero   Jan 04, 2020
For those of you wanting to hack the Android version of the game - this method won't work anymore as of 2.3.3. You can, however, hack the Assembly-CSharp.dll according to my github guide: https://github.com/qwerfd2/BadPiggiesEditLog/blob/master/README.md
Gamer   Mar 29, 2019
Could u mention the game version in which it works
Cat   Mar 15, 2019
I doesn't work
Hhs tức hả   Mar 01, 2019
12234567852
Someone   Feb 12, 2019
I tried it, but it just crashes
Leon   Feb 11, 2019
I did everything like in this Tutorial, but nothing changes
eeee   Jan 10, 2019
HELP!!! I cant find a 746ee37fafe29a34ba3f2032ea011e0a in apk Bad Piggies: HD1.5.0; Normal: 1.5.0 and 1.6.0 (I can send this APKs). but, can you, Nick get a link to "clean" APK, in which there is has a 746ee37fafe29a34ba3f2032ea011e0a file?
Laser   May 25, 2018
Whats the name of the level little pig adventure
Omar   May 07, 2018
There is no field of dreams file (i read the instructions)
2s   Mar 19, 2018
it crashes everytime i open it (the game)
Edwin Robert   Feb 20, 2018
Thanks for the info, Nick. I am currently still working on it.
Nick   Feb 19, 2018
Make sure you're using version 1.6.0 or earlier. It's possible really early versions may be different as well, since I only tested this on I believe versions around 1.5 and 1.6. Unfortunately it was quite a long time ago now and I don't remember exactly.
Edwin Robert   Feb 19, 2018
Hey, Nick. I did everything you said, had the same characters and lines as i had at the start but no matter what, it wouldn't change.
Mathew   Jan 27, 2018
Thanks lord publisher, works great! Some limits to have in mind or else it will hang/freeze: 1. Array_size: up to 8 (yes, you can only add +1 row to the default, or else the game dies) 2. Other lines you can delete in order to achieve the right size: "Generic data" lines below Element 36 and Element 37 3. Identification of some Element Types: 00: pig 04: fans -1 05: wooden box 07: wooden wheel -3 09-11: sack of rocks (simple/double/triple) 12: helix lateral 13: wooden wing 14: wooden tail 15: engine mid -2 16: blue rocket 17: metal box -3 18: tiny wheel -1 19: metal wing 20: metal tail 21: helix top 22: wheel selfpropelled 23: TNT -1 24: engine small -2 25: engine big 26: wheel 27: spring -1 28: umbrella -1 31: king pig 32: red rocket
BadPiggiesDogeHD   Nov 05, 2017
This actually worked but I didn't change the grid and changed every integer count for the items to 99 and 9 to conserve space
A Person   Oct 14, 2017
The file for the field of dreams does not exist on my apk file...
TheBadPiggiesYT   Oct 04, 2017
Can you do unlimited grid?
Killou LeGall   Jun 19, 2017
Can you please say us where is he "field of dreams" file in the latest version of Bad Piggies ?
Sean Borrowdale   Jun 04, 2017
where is the Level_Sandbox_06_data in notepad++? I cant find it
Roy Tal   Mar 23, 2017
do any one have these apk i want it thanks
Riki Club   Feb 26, 2017
Cant make it work. Please send me the working APK. Is for my son =)
Claudia Adina   Feb 23, 2017
kad...... what
Aaron Luis Tria   Oct 02, 2016
my game hangs in pressing the field of driems
Davey Visser   Jan 17, 2016
i cant adjust the amount of yellow umbrellas, because they have no integer count. is there another way?
Roberio Da Paoca   Oct 15, 2015
goooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooool
ShahBaz Talpur   Sep 08, 2015
I dont have 746ee37fafe29a34ba3f2032ea011e0a file. What to do?
Guido Gallwitz   Jun 24, 2015
Yeah... sry has read your commentary on top too late... i has changed all you wrote But i get not to change the size to the right one
Nick Vogt   Jun 24, 2015
I can't give out a bootleg APK for the game as that would land me in legal trouble. All I can do is show you how to tinker with yours.
Guido Gallwitz   Jun 23, 2015
Why you give us an ready apk from this... i cannot make the changes.... i've done serveral times without a chance to make it run