|This Article is up to date with Custom Stuff 2|
Slabs are also unique in that they can be stacked one on top of another, forming blocks. With Custom Stuff you'll still need to set up a normal block to accomplish this however. Of course, the ability to double stack isn't required; though it is a nifty feature.
Slab Example (CS2 0.9.10 and above)
config.addBlockIdProperty("cobaltSlabID", 2518); config.addBlockIdProperty("cobaltDoubleSlabID", 2519); mod.addBlock("cobaltSlab.js", "slab"); mod.addBlock("cobaltDoubleSlab.js", "normal");
id = config.getBlockId("cobaltSlabID"); name = "cobaltSlab"; material = "iron"; stepSound = "metal"; creativeTab = "buildingBlocks"; displayName = "Cobalt Slab"; doubleSlabId = config.getBlockId("cobaltDoubleSlabID"); doubleSlabMeta = 0; hardness = 5; resistance = 30; toolClass = "pickaxe"; harvestLevel = 2; textureFileXP = "cobaltSlab.png"; textureFileXN = "cobaltSlab.png"; textureFileYP = "cobaltBlock.png"; textureFileYN = "cobaltBlock.png"; textureFileZP = "cobaltSlab.png"; textureFileZN = "cobaltSlab.png"; addToCreative = true; toolClass = "pickaxe"; harvestLevel = 2;
id = config.getBlockId("cobaltDoubleSlabID"); name = "cobaltDoubleSlab"; material = "iron"; stepSound = "metal"; creativeTab = "buildingBlocks"; displayName = "Cobalt Double Slab"; drop = config.getBlockId("cobaltSlabID") + ":0 2"; hardness = 5; resistance = 30; toolClass = "pickaxe"; harvestLevel = 2; textureFileXP = "cobaltSlab.png"; textureFileXN = "cobaltSlab.png"; textureFileYP = "cobaltBlock.png"; textureFileYN = "cobaltBlock.png"; textureFileZP = "cobaltSlab.png"; textureFileZN = "cobaltSlab.png"; addToCreative = true;
Slab 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.
doubleSlabId and doubleSlabMeta These two values are used when you place two slabs on top of each other to make a single block.
drop If you do not set this value in your double slab block, then when you break the double slab, you will get the double slab block instead of two slab blocks.
Example Slab (CS1)
name="Obsidian Slab"; id=230; texturefile="terrain.png"; textureindex=183; textureindexnorth=37; textureindexsouth=37; textureindexeast=37; textureindexwest=37; type="slab"; material="rock"; stepsound="stone"; hardness=25; resistance=6000; iddropped=230; damagedropped=0; doubleslabid="231"; opacity=0; toolclass="pickaxe"; harvestlevel=3; // textureindex8=183; textureindexnorth8=37; textureindexsouth8=37; textureindexeast8=37; textureindexwest8=37; damagedropped8=0;
Slab Block Attributes
Below is a table of attributes available to slab-type blocks, including information on notable attributes.
This must be set to 'slab' in order for the block to function as a slab.
Setting this attribute to a low value prevents a rather pronounced visual bug. See Importance of the Opacity Attribute below.
Setting up Ceiling Slabs
In Minecraft 1.2, a new feature was added to slabs: the ability to place them on the underside of a block, thus causing them to occupy the top half of the space in which they are placed. This feature was then added to Custom Stuff in the 2.3.1 update. Unfortunately, it isn't perfect and requires some user-end effort to make the feature work correctly.
Ceiling slabs are actually a higher damage value of the base slab rather than a separate block. In keeping with vanilla Minecraft, the damage value (DV) of a ceiling slab is that of the normal slab +8. In the example above, you'll notice that the textureindex and damagedropped attributes are set not only for the basic, unnumbered version; but also for DV8. This is the reason for that.
The same correlation will hold true for every damage value. The ceiling slab for DV1 is DV9, and so forth. This unfortunately means that you can only have a total of eight functional damage values (0 - 7) for slab blocks since the upper eight are used for their ceiling-counterparts. Likewise, you'll always want to set the damagevalues attribute to 7 or less even though you're specifying some of the attributes for the higher values. That is unless of course you want to make the ceiling slabs their own unique items.
Fortunately, a lot of the work is coded into Custom Stuff. For example, you need only specify the doubleslabid once per pair, and it will carry over perfectly to its mate. In the example above, you can add another Obsidian Slab (of either damage value) to a placed slab (either normal or ceiling) and it will form the proper double slab. Other attributes like hardness will also carry over, though you may have to specify some as well. If something isn't working for both variations, just specify it for both DVs and it should work correctly.
Importance of the Opacity AttributeWhen making slabs, 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 to be cast on adjacent blocks 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 slab, which for this purpose is the same as a normal-type block, 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.