Jump to content

[1.14] Custom Stairs Registration


GyuGya_55

Recommended Posts

I need a little help to regirster a custom Stair block. I have to put something to where the null is right now, but I'm not sure what I should put there...

 

new Custom_Stone_Stairs(null, Block.Properties.create(Material.ROCK).hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.STONE))

 

 

Just in case you need it, here is the Stair blocks code:

 

package com.gyugya55.minecraftplus.blocks.buildingblocks;

import net.minecraft.block.BlockState;
import net.minecraft.block.StairsBlock;

public class Custom_Stone_Stairs  extends StairsBlock
{	

	public Custom_Stone_Stairs(BlockState state, Properties properties) {
		super(state, properties);
		setRegistryName("custom_stone_stairs");
	}
}

 

I would really appreciate your help.

Edited by GyuGya_55
Link to comment
Share on other sites

43 minutes ago, GyuGya_55 said:

null

?

Maybe go look at what that parameter is used for?

Maybe look at what other places call the stairs constructor and see what they pass?

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I should give a BlockState type and it will use it after that.

 

This is the code in the StairsBlock class, which I extended with my Custom_Stone_Stairs class.

 

protected StairsBlock(BlockState state, Block.Properties properties) {
      super(properties);
      this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(HALF, Half.BOTTOM).with(SHAPE, StairsShape.STRAIGHT).with(WATERLOGGED, Boolean.valueOf(false)));
      this.modelBlock = state.getBlock();
      this.modelState = state;
   }

 

Link to comment
Share on other sites

35 minutes ago, GyuGya_55 said:

this.modelBlock = state.getBlock();

this.modelState = state;

 

Great, what are these fields used for?

Have you figured out what you need to pass in yet?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I managed to figure it out but I had to redo the most of my project. I had to make a new block as well and I used it like this:

 

new Custom_Stone_Stairs(custom_stone.getDefaultState(), Block.Properties.from(custom_stone))

 

custom_stone is the name I registered it on.

 

 

Also thanks for trying to help me. <:

Link to comment
Share on other sites

 

14 hours ago, MatsCraft1 said:

Kind of off topic but do you know how to make the stairs become "corners"?

 

You don't have to do a lot. Basically you just have to copy the text from any vanilla stair blocks files and change the name and add your modId. Thats all. I also insert some code if you have any problems doing it by yourself. This was you will have a fully funcional stair block.

 

 

This is the registration. I had a lot of truble here.

ModBlocks:

Spoiler

 


package com.gyugya55.mymod.init;

import javax.annotation.Nullable;

import com.gyugya55.mymod.MyMod;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.StairsBlock;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.registries.ForgeRegistries;


public final class ModBlocks {
    public static Block plastered_stone;
    public static StairsBlock plastered_stone_stairs;

    private ModBlocks() {}
    
    
    public static void registerAll(RegistryEvent.Register<Block> event) {
    	
    	//custom_blocks
    	custom_stone = register("custom_stone", new Block(Block.Properties.create(Material.ROCK).hardnessAndResistance(1.5f, 6f).sound(SoundType.STONE)));
        custom_stone_stairs = register("custom_stone_stairs", new Custom_Stone_Stairs(custom_stone.getDefaultState(), Block.Properties.from(custom_stone)))

    }
        
    private static <T extends Block> T register(String name, T block) {
        BlockItem item = new BlockItem(block, new Item.Properties().group(MyMod.ITEM_GROUP));
        return register(name, block, item);
    }
    
    
    
    private static <T extends Block> T register(String name, T block, @Nullable BlockItem item) {
        ResourceLocation id = MyMod.getId(name);
        block.setRegistryName(id);
        ForgeRegistries.BLOCKS.register(block);
        if (item != null) {
            ModItems.BLOCKS_TO_REGISTER.put(name, item);
        }
        return block;
    }
}

 

Here is the
Custom_Stone_Stairs class:
 

Spoiler

package com.gyugya55.mymod.blocks.buildingblocks;

import net.minecraft.block.BlockState;
import net.minecraft.block.StairsBlock;

public class Custom_Stone_Stairs  extends StairsBlock
{	
	
	public Custom_Stone_Stairs(BlockState state, Properties properties) {
        super(state, properties);
	}
}

 

 

And here are the assets files:

Blockstate:

Spoiler

{
    "variants": {
        "facing=east,half=bottom,shape=straight":  { "model": "mymod:block/custom_stone_stairs" },
        "facing=west,half=bottom,shape=straight":  { "model": "mymod:block/custom_stone_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=straight": { "model": "mymod:block/custom_stone_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=straight": { "model": "mymod:block/custom_stone_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer" },
        "facing=west,half=bottom,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer" },
        "facing=north,half=bottom,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer", "y": 180, "uvlock": true },
        "facing=east,half=bottom,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner" },
        "facing=west,half=bottom,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner" },
        "facing=north,half=bottom,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner", "y": 180, "uvlock": true },
        "facing=east,half=top,shape=straight":  { "model": "mymod:block/custom_stone_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=straight":  { "model": "mymod:block/custom_stone_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=straight": { "model": "mymod:block/custom_stone_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=straight": { "model": "mymod:block/custom_stone_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=outer_right":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=outer_right": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "uvlock": true },
        "facing=east,half=top,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=outer_left":  { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=outer_left": { "model": "mymod:block/custom_stone_stairs_outer", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=inner_right":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=inner_right": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "uvlock": true },
        "facing=east,half=top,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=inner_left":  { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=inner_left": { "model": "mymod:block/custom_stone_stairs_inner", "x": 180, "y": 270, "uvlock": true }
    }
}

 

 

 

Models :

custom_stone_stairs.json

Spoiler

{
    "parent": "block/stairs",
    "textures": {
        "bottom": "mymod:block/custom_stone_bottom",
        "top": "mymod:block/custom_stone_top",
        "side": "mymod:block/custom_stone_side"
    }
}

 

 

custom_stone_stairs_inner.json

Spoiler

{
    "parent": "block/inner_stairs",
    "textures": {
        "bottom": "mymod:block/custom_stone_bottom",
        "top": "mymod:block/custom_stone_top",
        "side": "mymod:block/custom_stone_side"
    }
}

 

 

custom_stone_stairs_outer.json

Spoiler

{
    "parent": "block/outer_stairs",
    "textures": {
        "bottom": "mymod:block/custom_stone_bottom",
        "top": "mymod:block/custom_stone_top",
        "side": "mymod:block/custom_stone_side"
    }
}

 

 

I left our the icon and the lang jsons, but I think you can do that by yourself.

Edited by GyuGya_55
Link to comment
Share on other sites

  • 7 months later...

You don´t have to create your own StairsBlockClass.

in 1.15.2 this works fine for a StairsBlock out of the vanilla yellow_concrete:

public static final RegistryObject<Block> YELLOW_CONCRETE_STAIRS = BLOCKS.register("yellow_concrete_stairs", () -> new StairsBlock(YELLOW_CONCRETE, Block.Properties.create(
                        Material.ROCK, MaterialColor.YELLOW).sound(SoundType.STONE).lightValue(0).hardnessAndResistance(1.8F)));

It uses a seccond constructor in the vanilla StairsBlock-class, that wants a blockstate in a supplier as the first content..

So i created suppliers, wich contain the blockstates of the different vanilla concrete blocks.

 

I only create a custom SlabBlock-class (that extends the vanilla one) for my glazed terracotta slabs to make them rotatable north, east, south and west (for texture-patterns).

 

Maybe this is helpful for 1.14 too.

edit:

i noticed, the seccond constructor there is new in 1.15.

Edited by Drachenbauer
Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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