Jump to content

[1.9] [SOLVED] Changed block to have meta based variants, Registry name clash


Recommended Posts

Posted

Hi guys.

 

First of all you'll have to forgive me if I'm not too up on this whole "Why we now have to use Registry" methods instead of unlocalised names (if it wasn't broken why fix it? But anyway...)

 

I registered a block in my mod as a singular block for testing purposes and everything was fine. I have since changed its parent class to allow it to have variants and it's here I come unstuck.

 

First issue I faced was the ModelBakery throwing a null pointer when I tried to call registerItemVariants().

 

Second issue is this registry problem. I've looked at the code for this and there's no way round it. My block can't be registered again despite that version of it no longer existing.

 

Any help would be appreciated. Thanks guys!

 

final String colours[] = { "White", "Black" };

        ResourceLocation[] resLoc = new ResourceLocation[2];

        for(int i = 0; i < 2; i++)

            resLoc = new ResourceLocation("barrels:barrel" + colours);

        ModelBakery.registerItemVariants(Item.getItemFromBlock(BarrelsBlocks.barrelWhite), resLoc);

 

public static Block barrelBlock = new BarrelBlock("barrelBlock");

    public static Block barrelWhite = new MetaBarrelBlock("barrelWhite");

 

    public static void createBlocks() {

        GameRegistry.register(barrelBlock.setRegistryName("barrelBlock"));

        GameRegistry.register(barrelWhite.setRegistryName("barrelWhite"));

 

        GameRegistry.register(new BarrelsItemBlock(barrelBlock).setRegistryName(barrelBlock.getRegistryName()));

        GameRegistry.register(new BarrelsItemBlock(barrelWhite).setRegistryName(barrelWhite.getRegistryName()));

 

    }

Posted

ModelBakery.registerItemVariants(Item.getItemFromBlock(BarrelsBlocks.barrelWhite), resLoc);

GameRegistry.register(new BarrelsItemBlock(barrelWhite).setRegistryName(barrelWhite.getRegistryName()));

 

How do you expect

Item.getItemFromBlock()

to return anything other than null before you've told the Item registry what the ItemBlock is?

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

I was registering the ModelBakery in a block render register class, not the block registry class.

 

How did you expect me to know it was supposed to go in block registry when there's no documentation on it?

 

But I'll try it. Thank you for the response.

Posted

Yes I respect and gathered that from doing this revolutionary thing known as reading for myself...

 

I simply mentioned it because I know it probably wasn't clear in the code snippets that they were in seperate classes which was my bad.

 

The simple reason I'm using ModelBakery is the distinct lack of 1.9 method change explanations both in code and online. Therefore, I'm using it as it was what worked in 1.8.9.

 

I will investigate the ModelLoader method you suggest. Thanks for the advice.

 

I still have the registry problem however which is getting on my nerves purely because I can't even test to see if I've fixed the render issue until it decides to register properly.

Posted

I fixed it guys...

 

I was so used to setting an unlocalised name in the block constructor class I stupidly changed it to setRegistryName in there and was trying to cast it twice.

 

Everything is working fine... including your disliked ModelBakery method.

 

This can be marked as solved now.

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.