Jump to content

Recommended Posts

Posted

For the mod I'm creating, I need to create several different stairs and slabs. I've read that the stairs are easier, so for now they are my focus. I've followed through a couple tutorials as well as correlated with other mods, but I can't seem to get my stairs to function properly. Every time I attempt to run the JDK, the game crashes citing an error at line 30 of my event subscriber, where I begin to deal with the stairs. Do any of you have any ideas? Code can be found at https://github.com/OrangeySnicket/CosCraft-Mod/tree/WIP/workspace/InvestitureMod/src/main/java, with logs and crash reports only a couple directories up. There are a lot of blocks there, but the one I've chosen to start with is Bronze Stairs. Thanks in advance!

Posted
11 minutes ago, OrangeySnicket said:

Thanks in advance!

You cant do this

"static IBlockState modelState = ModBlocks.BRONZE_BLOCK.getDefaultState();"

 

ModBlocks.BRONZE_BLOCK is still null at this point in time.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
53 minutes ago, OrangeySnicket said:

How would I do that with everything still being null?

Pass it in through the constructor. Store the value of the block you need as a local variable in your registry event method. Yes you'll have to do this for each one.

29 minutes ago, Jummit said:

You can do this

No they cant because they need to have the value to create another block. And ObjectHolder values are not populated until after the registry events have fired.

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 hour ago, OrangeySnicket said:

What would your solution look like?

registerBlock(event)

   Block block:

   event.getRegistry().registerAll(

      ...

      block = new BronzeBlock(),

      new BlockStairs(block)...

   );

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I hope it doesn't seem like I want too be spoonfed too much, I really am trying here, but I still just don't get what you're trying to say. My initial thought was that I was supposed to create a whole new function that uses the registerBlock(event) method and use that to instantiate the stairs. I next guessed that maybe you meant  me to register all the regular blocks first as I am, then use the bronze block from there as my base. Neither of these worked, nor have a couple of other strange interpretations I've attempted. Is that intended to be its own module or to go inside one of the functions I've already created? And, either way, should any of those be curly brackets? Seriously, so sorry for not figuring this out more easily.

Posted
10 minutes ago, OrangeySnicket said:

I really am trying here, but I still just don't get what you're trying to say.

Its psuedocode.

8 hours ago, Animefan8888 said:

registerBlock(event)

This is your Register<Block> method you can use the one you already have.

 

8 hours ago, Animefan8888 said:

Block block:

This is a variable declaration at the top of the method for a Block type called block.

 

8 hours ago, Animefan8888 said:

event.getRegistry().registerAll

We call the register all method on the registry allowing us to pass in all of the blocks we want.

 

9 hours ago, Animefan8888 said:

...

This is here to say all your blocks you have.

 

9 hours ago, Animefan8888 said:

block = new BronzeBlock(),

This sets the block variable we created at the top of our registry method to the BronzeBlock and puts it in the registry.

 

9 hours ago, Animefan8888 said:

new BlockStairs(block)...

Create the stairs Block and pass in the block variable we created at the top of the method and just set to the Bronze Block(you may want it to be the getDefaultState() of the block).

9 hours ago, Animefan8888 said:

);

Close out of the registerAll method.

 

Is that enough explanation?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I... think so. My rewritten code now looks something like this:

public static void registerBlocks(Register<Block> event) {
		
		Block block;
		
		event.getRegistry().registerAll(
				new AluminumBlock().setRegistryName("aluminum_block").setTranslationKey(Investiture.MODID + "." + "aluminum_block"),
				new ZincBlock().setRegistryName("zinc_block").setTranslationKey(Investiture.MODID + "." + "zinc_block"),
				block = new BronzeBlock(),
				new BronzeStairs(block.getDefaultState()).setRegistryName("bronze_stairs").setTranslationKey(Investiture.MODID + "." + "bronze_stairs")
			);

with this as my constructor: 

public class BronzeStairs extends BlockStairs{
	
	public BronzeStairs(IBlockState modelState) {
		super(modelState);
		setCreativeTab(Investiture.INVESTITURE_TAB);
		setSoundType(SoundType.METAL);
		this.useNeighborBrightness = true;
	}
	
}

 

However, this continues to crash my game (according to my crash reports) as soon as I reach the event.getRegistry.registerAll statement.

Posted
1 hour ago, OrangeySnicket said:

However, this continues to crash my game (according to my crash reports) as soon as I reach the event.getRegistry.registerAll statement.

Post the crash report. And also step through your registry method with your IDEs debugger to find out what's happening.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Quote

Can't use a null-name for the registry, object Block{minecraft:air}.

That seems pretty self explanatory to me. The only issue is that Block's toString method goes based on its registry entry, which failed, so it returns AIR. You have a block that doesn't have a registry name.

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.

Posted

?‍♂️

 

Thanks... I feel really stupid. For whatever reason, I assumed that since I was only using block as a standin to give me a state, I didn't need to actually give it a registry name. Thank you all so, so much. Hopefully this understanding will transfer over nicely to slabs and I'll be able to work those out without incident. First, though, I need to get my textures working properly... Should be pretty easy. Seriously, so, so much thanks. 

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.