Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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. 

If you look at how vanilla implements it, you should see it's just as simple as creating a new `StairBlock` with the passed-in block supplier acting as a delegate to handle specific logic.

  • Author

Yeah, I tried that (using the code for the oak stair) and renaming everything and it was full of errors. I checked to make sure there weren't any missing imports but nope. 

  • Author

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?

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.