|This Article is up to date with Custom Stuff 2|
Stairs are a common block in Minecraft that allow for easy movement over raised terrain. Custom Stuff has the capability of adding new stairs as a Block. Stairs can have most of the same attributes as normal blocks, and for the most part can be coded in the same way.
Stairs cannot utilize metadata values to create variants because the metadata of stair blocks is instead used to track their orientation. Custom Stuff will give an error when you use metadata values, so you cannot, for example, make the stairs texture chang depending on its facing.
Example Stairs Block (CS2 0.9.10 and higher)
In this example, we're adding obsidian stairs using the textures found in the vanilla game. As with all examples, the mod.js file will be in the root of your project's directory, and the block file (obsidianStairs.js) will be in the /blocks/ folder within that directory.
config.addBlockIdProperty("obsidianStairsID", 217); mod.addBlock("obsidianStairs.js", "stairs");
name = "obsidianStairs"; id = config.getBlockId("obsidianStairsID"); material = "rock"; stepSound = "stone"; creativeTab = "buildingBlocks"; displayName = "ObsidianStairs"; hardness = 50; resistance = 6000; toolClass = "pickaxe"; harvestLevel = 3; textureFileXP = "/obsidian.png"; textureFileXN = "/obsidian.png"; textureFileYP = "/obsidian.png"; textureFileYN = "/enchantment_bottom.png"; textureFileZP = "/obsidian.png"; textureFileZN = "/obsidian.png"; addToCreative = true;
Stairs Block Attributes
textureFile and textureIndex
In CS2 versions for 1.4.7 and below, CS2 0.9.9 or below, textureFile was used to specify the texture sheet and textureIndex was used for identifying the specific icon within the texture sheet. If using CS2 0.9.9 or lower, make sure to use both of these attributes.
Stairs cannot use Damage Values to create variants because the metadata of stair blocks are instead used to track the direction they're facing.
Example Stairs Block
name="Snow Stairs"; id=226; texturefile="terrain.png"; textureindex=66; type="stairs"; material="ground"; stepsound="grass"; hardness=0.1; resistance=1; iddropped=226; opacity=0; toolclass="shovel"; harvestlevel=0;
Stairs Block Attributes
Below is a table of attributes available to stairs-type blocks, including information on notable attributes.
This must be set to 'stairs' in order for the block to function as stairs.
Setting this attribute to a low value prevents a rather pronounced visual bug. See Importance of the Opacity Attribute below.
Importance of the Opacity AttributeWhen making stair blocks the opacity attribute should always be set to a value of ten or less even if the the material being used not being intrinsically translucent. This is done to prevent a visual 'bug', demonstrated by the picture at right, which causes a shadow on the inner angle of the block regardless of light level. This 'glitch' occurs because Minecraft calculates the light level of the area 'inside' the block based on what's immediately below it. Because a block normally blocks all light, the boundary of the stairs block (the box you see when you place your reticule on it) forces the game to calculate the light level as being 0 on the ground beneath the block. Setting the opacity to a low value fixes this issue.
This is also why stairs, slabs, and doors in the vanilla game don't block light entirely even when they logically should.