Jump to content

[SOLVED][1.10.2] The Nightmare of Variants registering


Recommended Posts

Posted

I may be wrong, but it looks like we're supposed to write the array of strings and then feed it into the constructor. That's how we tell the class what our variants are named. So think about what you're trying to do and then write it.

I'm not stupid at all. I just asking, how I can obtain list of all meta's names? If I using while cycle with names[ i ] = BlockNewStoneBricks.BrickType.byMetadata(i).getName(); throwing an excrption, so I just can't find any way to proprly obtain name of all metas as array. Of course I can register them manually, but hardcoding isn't our way, right? Also, what if I would have 10, 20 blocks with 3 to 10 metas each?

Posted

block.getBlockState().getValidStates();

 

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

Yes.  And you know what you can do?

 

Block#getMetaFromState(IBlockState)

 

Gasp. Shock. Awe.

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'm entangled a bit. That move gives me int of every meta through loop section, but I can't find a way to convert it to meta's name. block.getStateFromMeta().toString() is deprecated and crashing Minecraft.

Posted

All variants will have exactly the same name unless you, personally, did something to change that.  Did you?

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

That's true, but I'm in search of set-and-forget method which I can feed with any Block-extending object in future and not to hardcode an array of it's meta names, enlarging code by another 10-20 lines.

Posted

You're going to need to hardcode those names in some manner: the strings must exist in the code.  At best you can concatenate the metadata value with the block's general name and then localize it.

 

e.g. "minecraft.blockstone_1" and "minecraft.blockstone_2"

 

Which would be your previous post of converting the metadata from an integer to a string (just concatenate it onto the end of the result of getUnlocalizedName).  Or better yet, override getUnlocalizedName to do that for you.

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

Ok, I just hardcoded all names into array and pushed it to ItemMultiTexture to register and got 4 correct ItemBlocks in creative inventory, that's better than nothing.

 

Now I'm scratching head - how I should name correct .json for model and how to point at textures to put on? I have no such problems with single block w/out metas, it was easy, but the same way isn't working here.  :-[

Posted

The examples in vanilla code are variable blocks like stone. Each has an associated enum, and each enum has a set of arbitrary names (e.g. stone, andesite, diorite...) bound to numeric (metadata) values. That's why I said that the strings are something you write.

 

They're usually an essential aspect of your mod's concept, so they're something that you are making up. You're the one making the mod, so only you know what your variants mean. You create the names from your own imagination. The names describe what you set out to code in the first place.

 

It shouldn't be this hard. I'm reminded of a line from the movie Cool Hand Luke: "What we have here is a failure to communicate..."

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.