Auto-Tiling
There are times where you would want a tile to change it's look depending on what other tiles are around it. It could be objects like roofing tiles or fences. And there are times where you want a tile to change the tiles around it, again like roofing and fences. Auto-Tiling will allow you to do the following;
- Change the tile you are placing.
- Change tiles up to 2 blocks away from the tile.
- Block placing your tile unless certain conditions are met.
Contents
Tutorial: How to do Simple Stairs
This tutorial focuses on the typical use of Auto-Tile, but it might be a bit advanced for starting modders. Toketsupuurin's tutorial breaks things down into smaller chunks and covers some of the more unusual aspects of Auto-Tile.
Before starting this tutorial, be sure to look at Modding#Setting up for Mod Creation. There will be a reference file at the end of this tutorial which will have a completed version of the stairs.
To start this tutorial off, you will need 3 Tiles. These tiles should similar to the following;
Image containing 3 stair tiles.
For the purposes of this tutorial, the stair on the left will be the "Outer" Stairs, the one on the right will be "Inner" stairs and the one in the middle will be known as "Straight.
The Outer and Inner stairs should have the following in their *.tile files.
{ "__inherits" : "staxel/tileObject/base.config", "code" : "mods.tutorial.MCStairs.inner", "voxels" : "mods/[Folder Name]/InnerStair.qb", "categories" : [ "stair" ], "representativeTile" : "mods.tutorial.MCStairs.straight" }
Use Inner and Outer depending on which tile this is. Also be sure to change the folder name to the folder you store these tiles in. These tiles are now effectively done. What this does, is set these stairs up as normal Tile Objects. You really do not need to change much about these tiles. The one extra change however is "representativeTile". This will make it so you get the straight tile back instead of the corner pieces.
The next step is to set up the Straight tile file;
{ "__inherits" : "staxel/tileObject/base.config", "code" : "mods.tutorial.MCStairs.straight", "voxels" : "mods/[Folder Name]/StraightStair.qb", "categories" : [ "stair" ], "autoTileInfo" : [ ] }
This file is almost set up. The last property is however not complete, as this will be the focus of this tutorial. Feel free to skip to the end if you don't want to figure out what all of this means.
First off lets think of how minecraft steps work. Or rather when they change from straight stairs. Here is a list of the ways they change;
- If a stair is behind the stair you are placing, then you will place a corner piece. This corner piece is the Outer stair from before. There are two orientations to this.
- If a stair is infront the stair you are placing, then you will place a corner piece. This corner piece is the Inner stair from before. There are two orientations to this.
- If there is a stair to the left of the stair you are placing, it will turn into a corner piece if it doesn't line up. (Not Completed with this tutorial.)
- If there is a stair to the right of the stair you are placing, it will turn into a corner piece if it doesn't line up. (Not Completed with this tutorial.)
Lets start adding in these interactions then. Lets start off with changing how the stair will react when being placed in front of another stair. The following should be added to the file;
"autoTileInfo" : [ { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.straight", "mods.tutorial.MCStairs.outer", "mods.tutorial.MCStairs.inner"], "rotationToLookFor" : 1 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 0 } ] } ]
This should set the stair up to do the following;
An image of the stair in front of the three different stairs.
That is, it will turn the tile into a specific model if the stair behind it is facing right. Feel free to build these files and test out how it works in game. If it does not look like the image, then your stairs are probably not in the correct rotations. You'll need to rotate the tiles, as the rest of this tutorial will assume this section works. There will be a reference file at the end of this tutorial that will have all of the stairs in their correct rotations. Do note that it will only work on one direction and not both directions at this point in time.
Now what this section does should be self explanatory if you look at it. We search the tile behind the one we are looking at by setting "direction" to "back". We then look for one of the three stairs we made, and make sure it is in a set rotation. If this is the case, then we want to place inner down instead of straight and make it a very specific rotation. And that is it.
Now we make it for when the tile behind the stair is facing left instead of right.
"autoTileInfo" : [
{ //Behind stair facing right. }, { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.straight"], "rotationToLookFor" : 3 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 3 } ] }, { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.inner"], "rotationToLookFor" : 2 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 3 } ] }, { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.outer"], "rotationToLookFor" : 0 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 3 } ] }
]
Now this is long, but it is needed. This is long due to the fact that different tiles will rotate slightly differently to each other. But these should be self explanatory, especially when considering the above section.
With that done, we can implement the other direction. If you want to do this yourself, feel free to do so. Otherwise here is a completed file;
{ "__inherits" : "staxel/tileObject/base.config", "code" : "mods.tutorial.MCStairs.straight", "voxels" : "mods/Minecraft Stairs/StairDark1.qb", "categories" : [ "dark", "clean", "coloured", "brown", "stair" ], "autoTileInfo" : [ { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.straight", "mods.tutorial.MCStairs.outer", "mods.tutorial.MCStairs.inner"], "rotationToLookFor" : 1 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 0 } ] }, { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.straight"], "rotationToLookFor" : 3 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 3 } ] }, { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.inner"], "rotationToLookFor" : 2 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 3 } ] }, { "directionsToLookIn" : [ { "direction" : "back", "tilesToLookFor" : [ "mods.tutorial.MCStairs.outer"], "rotationToLookFor" : 0 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.inner", "rotation" : 3 } ] }, { "directionsToLookIn" : [ { "direction" : "front", "tilesToLookFor" : [ "mods.tutorial.MCStairs.straight"], "rotationToLookFor" : 1 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.outer", "rotation" : 1 } ] }, { "directionsToLookIn" : [ { "direction" : "front", "tilesToLookFor" : [ "mods.tutorial.MCStairs.straight"], "rotationToLookFor" : 3 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.outer", "rotation" : 0 } ] }, { "directionsToLookIn" : [ { "direction" : "front", "tilesToLookFor" : [ "mods.tutorial.MCStairs.outer"], "rotationToLookFor" : 2 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.outer", "rotation" : 1 } ] }, { "directionsToLookIn" : [ { "direction" : "front", "tilesToLookFor" : [ "mods.tutorial.MCStairs.outer"], "rotationToLookFor" : 3 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.outer", "rotation" : 0 } ] }, { "directionsToLookIn" : [ { "direction" : "front", "tilesToLookFor" : [ "mods.tutorial.MCStairs.inner"], "rotationToLookFor" : 0 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.outer", "rotation" : 1 } ] }, { "directionsToLookIn" : [ { "direction" : "front", "tilesToLookFor" : [ "mods.tutorial.MCStairs.inner"], "rotationToLookFor" : 3 } ], "results" : [ { "tileToPlace" : "mods.tutorial.MCStairs.outer", "rotation" : 0 } ] }, ] }
And with that, you have a set of minecraft stairs. If you want to try making these stairs affect the stairs nearby, use "direction" in "results". But otherwise, you are ready to go.
Here is the example file that implemented this tutorial.
Config Options
An important thing to note, is that Auto-tiling is not by it's own. It must be placed within a Tile. Auto-Tiling allows multiple different outcomes to occur, as such the following property should be read before continuing.
"autoTileInfo"
AutoTileInfo is the property which contains all the properties listed below. However this is being mentioned, due to a special condition.
AutoTileInfo is a List of Blobs. This means you can specify multiple different groups of autoTiling in the same tile. It will commonly look like;
"autoTileInfo" : [ { //Group 1 }, { //Group 2 }, { //Group 3 } ]
Another thing to note is that these groups are done in order, with higher groups going first. This can be taken advantage off and make simpler files, as later groups will override earlier results. Take a look at Rope Fence Corner to see this in action.
"directionsToLookIn"
This is yet another list of List of Blobs. It will commonly look like the following;
"DirectionsToLookIn" : [ { "direction" : "", "secondDirection" : "", "tilesToLookFor" : [], "tileCategoriesToLookFor" : [], "rotationToLookFor": 0 }, { //Direction 2 } ],
"direction"
Valid options (String): "right", "left", "front", "back", "up", "down", "none"
Default Value: No default value is specified. Always need to provide your own.
This is the direction that it will check first. That is, if you say "right" it will check the tile to the right.
"rotationToLookFor"
Valid options (Integer): 0,1,2 or 3
Default Value: If not specified, will not care about rotation.
If the tile that is searched, the one specified with #"direction" and #"secondDirection", has this specific rotation, then proceed to #"results". Otherwise reject it.
"secondDirection"
Valid options (String): "right", "left", "front", "back", "up", "down", "none"
Default Value: If not specified, will default to "none".
This is the direction that will check second. This will force the checked tile to be one further That is, if you say "right" for direction, then "right" for secondDirection it will check the tile, two tiles to the right.
"tileCategoriesToLookFor"
Valid options (List of String): A list of any valid strings.
Default Value: If not specified, will not look for categories. Should specify either "tileCategoriesToLookFor" or "tilesToLookFor".
If the tile that is searched, the one specified with #"direction" and #"secondDirection", has any of these categories, then proceed to #"results". (As long as it is not rejected.)
"tileCategoriesToReject"
Valid options (List of String): A list of any valid strings.
Default Value: If not specified, will not look for categories. Should specify either "tileCategoriesToLookFor" or "tilesToLookFor".
If the tile that is searched, the one specified with #"direction" and #"secondDirection", has any of these categories, then reject going to #"results".
"tilesToLookFor"
Valid options (List of String): A list of strings each containing the code to a Tile.
Default Value: If not specified, will not reject any tiles.
If the tile that is searched, the one specified with #"direction" and #"secondDirection", has a code in this list, then proceed to #"results". (As long as it is not rejected.)
"tilesToReject"
Valid options (List of String): A list of strings each containing the code to a Tile.
Default Value: If not specified, will not reject any tiles.
If the tile that is searched, the one specified with #"direction" and #"secondDirection", has a code in this list, then reject going to #"results".
"lookFromOverride"
Valid options (String): "right", "left", "front", "back", "up", "down", "none"
Default Value: No default value is specified. Always need to provide your own.
This is set the central tile to work from. Both "direction" and "secondDirection" will work based off of this direction.
"results"
This is yet another list of List of Blobs. It will commonly look like the following;
"results" : [ { "tileToPlace" : "", "direction" : "", "secondDirection" : "", "rotation" : "" }, { //Group 2 } ],
"alt"
Valid options (Integer): 0, 1, 2 or 3
Default Value: If not specified, will place in a random alt.
This will be the number of the alternative look (alt) that the tile will have.
"tileToPlace"
Valid options (String): A strings containing the code to a Tile.
Default Value: If not specified, will place the the tile.
This will be the tile that is placed in the place specified by #"direction" and #"secondDirection".
"direction"
Valid options (String): "right", "left", "front", "back", "up", "down", "none"
Default Value: No default value is specified. Always need to provide your own.
This is the direction that it will check first. That is, if you say "right" it will check the tile to the right.
"rotation"
Valid options (Integer): 0, 1, 2 or 3
Default Value: If not specified, will place in a random rotation.
This will be the rotation that the tile is placed in.
"secondDirection"
Valid options (String): "right", "left", "front", "back", "up", "down", "none"
Default Value: If not specified, will default to "none".
This is the direction that will check second. This will force the checked tile to be one further That is, if you say "right" for direction, then "right" for secondDirection it will check the tile, two tiles to the right.