Jump to content

Register Blocks with Enum still not fixed


shane020482

Recommended Posts

Has anybody figured out how to register Blocks with Property Enum on 1.12.2, Old code https://pastebin.com/aBguc6T3 Problem is GameRegistry.register is now hidden and now requires either ForgeRegistries constants Or the registry passed in during the RegistryEvent.Register<T> event and i cant figure out how to get this to work.

 

Edit: I hate to be such a bother but I'v gotten the Blocks and ItemBlocks in game however I'm still getting Item Inventory console errors and it doesn't work with Forge Blockstates so I must still have something wrong in my ItemBlock Registry.

ItemBlock Registry

https://pastebin.com/xYVjuwCA

Console

https://pastebin.com/iJpb3LpQ

Edited by shane020482
Update
Link to comment
Share on other sites

I know how to register basic blocks, I actually like the new method of registering but to register a block that uses a enum is where im having trouble. Iv tried several diff ways to register a enum block using the event registry without any luck.

Link to comment
Share on other sites

52 minutes ago, shane020482 said:

I know how to register basic blocks, I actually like the new method of registering but to register a block that uses a enum is where im having trouble. Iv tried several diff ways to register a enum block using the event registry without any luck.

Enum? Do you mean a block with a state property? Its done exactly the same way...

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

The only loop you would need would be to register models for the ItemBlock variants, if applicable.

For all variant blocks, you can use this:

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java#L65-L71

(Line 70 eventually resolves to ModelLoader.setCustomModelResourceLocation(iblock, block.getMetaFromState(state), new ModelResourceLocation(block.getRegistryName(), str)); )

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

Honestly, you're being so vague it'd difficult to understand what you're trying to do.

Show all your code related to what you're trying to do. 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Register the block: looks fine

Register the item: looks fine

Register the item's model: see prior post

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

Take my code, put it inside of your line 95, replacing my line 70 with the equivalent in my prior post. Which I have to edit, because I forgot the new ModelResourceLocation bit.

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

Yes. You didn't do this:

55 minutes ago, Draco18s said:

replacing my line 70 with the equivalent in my prior post.

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

public void _registerBlockWithCustomItem(Block block, ItemBlock iBlock, String registryname) {
		super._registerBlockWithCustomItem(block, iBlock, registryname);
		StateMapperBase b = new DefaultStateMapper();
		net.minecraft.block.state.BlockStateContainer bsc = block.getBlockState();
		ImmutableList<IBlockState> values = bsc.getValidStates();
		for(IBlockState state : values) {
			String str = b.getPropertyString(state.getProperties());
			ModelLoader.setCustomModelResourceLocation(iBlock, block.getMetaFromState(state), new ModelResourceLocation(block.getRegistryName(), str)); 
		}
	}

 

Link to comment
Share on other sites

That should work. You still need to invoke that method of course, but it looks correct.

And it needs to be client-side-only, as does all other model registration code.

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

29 minutes ago, shane020482 said:

nope

 

You don't need that line. I only highlighted lines 65 through 71, that was from line 64.

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

Finally got the blocks in game, just like i did in older versions created my own itemblockenun class then just register like normal in 1.12 but call the itemblockenum class instead of ItemBlock. Still need to get the item models to register but that shouldn't be too hard

@SubscribeEvent
    public static void registerItemBlocks(RegistryEvent.Register<Item> event)
    {
        event.getRegistry().registerAll(new ItemBlock(block_test).setRegistryName(block_test.getRegistryName()));
         
        event.getRegistry().registerAll(new itemblockenum(block_test_enum).setRegistryName(block_test_enum.getRegistryName()));
    }  

 

2018-05-22_07.16.37.png

Link to comment
Share on other sites

9 hours ago, diesieben07 said:

That has nothing to do with models. ItemBlock by default only works for blocks without variants. Look at the vanilla blocks that have variants and the ItemBlock classes they use.

This is what i needed i was just overthinking this and needed someone to tell me to go back and look at the basics. Thanks:D

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.

Announcements



×
×
  • Create New...

Important Information

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