Jump to content

Recommended Posts

Posted

Can somebody give me a comprehensive tutorial on how to make a custom stair block? I'm trying to make some sort of black sand and want all the smooth and stone versions like vanilla. I tried using code from various mods but it didn't work. I also tried just doing it myself but that didn't work. 

Posted

Error: 

src\main\java\net\the_typholorian\adventurous\init\AdventurousModBlocks.java:25: error: cannot find symbol
    public static final Block VOLCANIC_SANDSTONE_STAIRS = register("volcanic_sandstone_stairs", new StairBlock(VOLCANIC_SANDSTONE.defaultBlockState(), BlockBehaviour.Properties.copy(VOLCANIC_SANDSTONE)));
                                                                                                                                 ^
  symbol:   method defaultBlockState()
  location: variable VOLCANIC_SANDSTONE of type RegistryObject<Block>

Code:

public static final Block VOLCANIC_SANDSTONE_STAIRS = register("volcanic_sandstone_stairs", new StairBlock(VOLCANIC_SANDSTONE.defaultBlockState(), BlockBehaviour.Properties.copy(VOLCANIC_SANDSTONE)));

Do I need to make VolcanicSandstoneStairsBlock.class file?

Posted

If you are posting compiler errors, you are in the wrong place. You want a learning java forum.

 

You also don't understand how static initalisation or suppliers/deferred access works.

https://forums.minecraftforge.net/topic/122471-custom-boat-119/#comment-538014

https://forums.minecraftforge.net/topic/123532-crash-in-my-mods-fluid-setup-class-what-am-i-doing-wrong-here-solved/#comment-536786

or you can search to find the many other threads where this is discussed.

 

The correct code uses RegistryObjects properly - something like (untested pseudo code)

public static final DeferredRegister<Block> BLOCKS = ...
// Use a registry object
public static final RegistryObject<Block> VOLCANIC_SANDSTONE_STAIRS = BLOCKS.register("volcanic_sandstone_stairs",
  // deferred access to the constructor - you can't create the actual blocks until the RegisterEvent happens
  () -> new StairBlock(
      // VOLCANIC_SANDSTONE is a RegistryObject<Block>/Supplier<Block> so you use get() for the real Block.
      VOLCANIC_SANDSTONE.get().defaultBlockState(), 
      BlockBehaviour.Properties.copy(VOLCANIC_SANDSTONE.get()));

You will also need to make sure the VOLCANIC_SANDSTONE RegistryObject  is registered with the DeferredRegister before the stairs, otherwise those get()s will fail.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
4 hours ago, warjort said:

You will also need to make sure the VOLCANIC_SANDSTONE RegistryObject  is registered with the DeferredRegister before the stairs, otherwise those get()s will fail.

Quick correction to warjort's example, you should be passing in a `Supplier<BlockState>` instead of the raw `BlockState` to support lazy loading such that the parameter is not reliant on registry order. Forge patches this constructor in.

Posted
5 minutes ago, ChampionAsh5357 said:

Quick correction to warjort's example, you should be passing in a `Supplier<BlockState>` instead of the raw `BlockState` to support lazy loading such that the parameter is not reliant on registry order. Forge patches this constructor in.

The original poster still needs the correct order to handle the block properties getting copied from the original block.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.