Jump to content

Recommended Posts

Posted

Stairs are easier than slabs. For complete source listing look at https://github.com/localtoast9001/forge-mods/tree/1.8.

 

How stairs work in the game

Each stair is a block derived from net.minecraft.block.BlockStairs. The base class controls collision, placement, and block state properties. The stairs block references its full cube block object for material properties. The stairs block has a lot of different variants through its block state to describe the stair's orientation. Since each variant potentially has its own model, you'll need to test all combinations.

 

Design Considerations

I originally wanted to do stairs for stained bricks. The cube block for stained bricks is one block with 16 variants for each color. In 1.7, the stairs block uses all the metadata for orientation, so I needed 16 different types of stairs. I continued this pattern in 1.8, even though BlockStairs now takes a full IBlockState in its constructor. I didn't experiment.

 

Classes you will need

A stairs block class derived from net.minecraft.block.BlockStairs - This is used for block registration and to initialize the base class with properties from the cube block. To get a block state object from the cube block, you can call block.getStateFromMeta(int metadata). metadata is 0 if your cube block has no variants.

Example:

/**
* Stained brick stairs.
*
*/
public class BlockStainedBrickStairs extends BlockStairs {
    /**
     * Initializes a new instance of the BlockStainedBrickStairs class.
     * @param block the stained bricks block.
      */
    public BlockStainedBrickStairs(
        final BlockStainedBricks block) {
        super(block.getStateFromMeta(0));

 

Block Registration

Stairs reuse the common ItemBlock class, so stairs are registered like any other normal block in your Mod's init event handler.

Example:

            BlockStainedBrickStairs stairs = new BlockStainedBrickStairs(
                stainedBrickBlocks);
            GameRegistry.registerBlock(stairs, stairs.getId());

Models

You need one blockstate file and 3 model files (normal, inner, and outer) for your stairs.

Example/template blockstate file:

{
    "variants": {
        "facing=east,half=bottom,shape=straight":  { "model": "morematerials:stained_bricks_block_black_stairs" },
        "facing=west,half=bottom,shape=straight":  { "model": "morematerials:stained_bricks_block_black_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=straight": { "model": "morematerials:stained_bricks_block_black_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=straight": { "model": "morematerials:stained_bricks_block_black_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_right":  { "model": "morematerials:stained_bricks_block_black_outer_stairs" },
        "facing=west,half=bottom,shape=outer_right":  { "model": "morematerials:stained_bricks_block_black_outer_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=outer_right": { "model": "morematerials:stained_bricks_block_black_outer_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=outer_right": { "model": "morematerials:stained_bricks_block_black_outer_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_left":  { "model": "morematerials:stained_bricks_block_black_outer_stairs", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=outer_left":  { "model": "morematerials:stained_bricks_block_black_outer_stairs", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=outer_left": { "model": "morematerials:stained_bricks_block_black_outer_stairs" },
        "facing=north,half=bottom,shape=outer_left": { "model": "morematerials:stained_bricks_block_black_outer_stairs", "y": 180, "uvlock": true },
        "facing=east,half=bottom,shape=inner_right":  { "model": "morematerials:stained_bricks_block_black_inner_stairs" },
        "facing=west,half=bottom,shape=inner_right":  { "model": "morematerials:stained_bricks_block_black_inner_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=inner_right": { "model": "morematerials:stained_bricks_block_black_inner_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=inner_right": { "model": "morematerials:stained_bricks_block_black_inner_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=inner_left":  { "model": "morematerials:stained_bricks_block_black_inner_stairs", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=inner_left":  { "model": "morematerials:stained_bricks_block_black_inner_stairs", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=inner_left": { "model": "morematerials:stained_bricks_block_black_inner_stairs" },
        "facing=north,half=bottom,shape=inner_left": { "model": "morematerials:stained_bricks_block_black_inner_stairs", "y": 180, "uvlock": true },
        "facing=east,half=top,shape=straight":  { "model": "morematerials:stained_bricks_block_black_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=straight":  { "model": "morematerials:stained_bricks_block_black_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=straight": { "model": "morematerials:stained_bricks_block_black_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=straight": { "model": "morematerials:stained_bricks_block_black_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=outer_right":  { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=outer_right":  { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=outer_right": { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=outer_right": { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=outer_left":  { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=outer_left":  { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=outer_left": { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=outer_left": { "model": "morematerials:stained_bricks_block_black_outer_stairs", "x": 180, "uvlock": true },
        "facing=east,half=top,shape=inner_right":  { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=inner_right":  { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=inner_right": { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=inner_right": { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=inner_left":  { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=inner_left":  { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=inner_left": { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=inner_left": { "model": "morematerials:stained_bricks_block_black_inner_stairs", "x": 180, "uvlock": true }
    }
}

Normal stairs model example/template:

{
    "parent": "block/stairs",
    "textures": {
        "bottom": "morematerials:blocks/stainedbricks_black",
        "top": "morematerials:blocks/stainedbricks_black",
        "side": "morematerials:blocks/stainedbricks_black"
    }
}

Inner stairs model example/template:

{
    "parent": "block/inner_stairs",
    "textures": {
        "bottom": "morematerials:blocks/stainedbricks_black",
        "top": "morematerials:blocks/stainedbricks_black",
        "side": "morematerials:blocks/stainedbricks_black"
    }
}

Outer model example/template:

{
    "parent": "block/outer_stairs",
    "textures": {
        "bottom": "morematerials:blocks/stainedbricks_black",
        "top": "morematerials:blocks/stainedbricks_black",
        "side": "morematerials:blocks/stainedbricks_black"
    }
}

Quirks

Using Neighbor brightness - In your stairs block class, set the useNeighborBrightness property to true. Otherwise, you will get dark spots on neighboring bricks when you place the stairs.

        this.useNeighborBrightness = true;

Model Registration - Like any other block in 1.8, the model has to be registered for display as an inventory icon. There are other posts on the subject, but essentially you need to do the following:

        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(
                item,
                metadata,
                new ModelResourceLocation(
                    MODID + id,
                    "inventory"));

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.