diff --git a/Adding-support-for-a-new-Mod.md b/Adding-support-for-a-new-Mod.md new file mode 100644 index 0000000..5d2a639 --- /dev/null +++ b/Adding-support-for-a-new-Mod.md @@ -0,0 +1,55 @@ +Crafting Guide represents all its data in the form of simple configuration files and images. Anyone with a text editor can easily create everything needed to add a new mod. Here's a guide to how create everything from scratch. + +## 0. About Slugs + +This is a term which comes up a lot in Crafting Guide, so it's best to be clear about these up front. A slug is a version of a thing's name which has any troublesome characters removed, and which has been cleaned up for easy use in programs. These are generally created with the following steps: + +1. Replace any non-alphanumeric character with an `_` +2. Replace any duplicated `_` with a single one +3. Convert all letters to lowercase. + +In other words, you'd convert something like "Oak Wood Planks" to "oak_wood_planks" or "(Empty) Fuel Can" to "empty_fuel_can". + +## 1. Set up Minecraft + +The easiest way to access all the raw information is through the game itself. Start by installing both the mod you want to add and [NotEnoughItems](http://chickenbones.net/Pages/links.html) (along with its dependency, CodeChickenCore). Then, launch Minecraft, and create a new world for yourself. + +## 2. Fork the repo + +Create a fork of this repo in which to make your changes. If you're not sure how to do this, check out GitHub's [help page](https://help.github.com/articles/fork-a-repo/) to get started. This will guide you through the process starting from the GitHub website all the way through having the code on your own computer. + +## 3. Create a new directory + +Open up your clone of the Crafting Guide repository, and create a new directory: `./src/data//` where the `mod_slug` is the slug generated from the Mod's official name. + +## 2. Export the images + +When you pop open your inventory, you'll see the NotEnoughItems (NEI) interface. Click on "NEI Subsets", then "Mod", and finally, hold Shift and click the mod you want to work with. This will restrict the NEI display to only the items from that mod. + +Next, you'll want to drill through the Options, Tools, and Data Dumps buttons. Mid-way down, you'll see an "Item Panel" row. Click the "CSV" button until it reads "PNG", and click the button to its left until it reads "48x48". Finally, click the "Dump" button. + +Now, if you check your world's directory, you should see a `dumps/itempanel_icons` directory containing all the images for that mod's items. These will need to be renamed by converting each file name into the slug version. + +Finally, create a new `images` directory in the repo under your mod's directory and copy all the images into it. + +## 3. Create the data file + +Next is the hard part. Start by creating a new file named `-.cg` in your Mod's directory. Now, for each item whose image your exported, follow the [Crafting Guide Data Format V2](https://github.com/andrewminer/crafting-guide/wiki/Crafting-Guide-Data-Format-V2) reference to enter all the items, recipes, and other information needed to describe your mod. + +Be sure to test frequently using the `./script/verify` script included in the repo. + +## 4. Test Locally + +As you're going along, you may find it helpful to verify your data file as you're going along. To do so, first add your new file name to the `DefaultBookUrls` list in `./src/scripts/constants.coffee`. Then, on the command line, use the `grunt` command to rebuild the project. Finally, run `./scripts/server` to start a local server. At this point, you should have your own version of Crafting Guide (with your mod included) running at [http://localhost:8000](http://localhost:8000). + +Test by crafting the various items in your mod, and walking through the steps to ensure everything makes sense. In particular, you should look for: + +* Do the proper images show up for each item? If not... + * Check that the item name is correct in the data file, and that the image file has the matching + slugified version of that name. + * Check that the image file was copied to the `./dist/data//images` directory. If not, you + may need to rebuild your project using `grunt`. +* Do the recipes show each item in the correct place on the grid? If not... + * Check that the pattern's numbers are correct. Remember, it starts counting at 0, not 1. + * Check that you added the right number of `.`s to position things in the right places. + * Check that you spelled each item correctly in the `input` section \ No newline at end of file