Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10] Custom ItemBlock class?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Draco18s

[1.10] Custom ItemBlock class?

By Draco18s, July 18, 2016 in Modder Support

  • Reply to this topic
  • Start new topic
  • Prev
  • 1
  • 2
  • Next
  • Page 2 of 2  

Recommended Posts

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted July 19, 2016

One last question:

Any way to do something similar with regular items? All I'm seeing are these predicate overrides which point to alternate model jsons.

 

Its fine if not, just would've been nice.

  • Quote

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.

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5100 posts
Posted July 19, 2016

Any

Item

can use a model specified by any blockstates JSON. Regular items obviously don't have a

Block

to get the variant names from, but you can use an enum like

ItemDye

and

ItemFishFood

do.

 

In my

ModModelManager

class, all of the overloads of

registerItemModel

are designed to be used for

Item

s that have a single model. The overloads of

registerItemModelForMeta

are designed to be used for

Item

s that have a different model for each metadata value.

 

All of these overloads just boil down to a single

ModelLoader.setCustomMeshDefinition

or

ModelLoader.setCustomModelResourceLocation

call with various default values.

  • Quote

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted July 19, 2016

I was looking at

ItemDye

and it forwards everything to a bunch of models.

 

But yeah, I have an enum and the ordinal of each one would be the metadata involved, but I couldn't get things pointed at a block state file in a way that the game liked.  I had things going down the same path as the metadata block, but I either got purple squares and no errors or invisible items (the textures in use at the time were vanilla items).

 

It was basically ignoring the "variants" section in the json file, as far as I could tell (as I had one or two matching the variants generated by the code below, but I wasn't getting "could not find variant in file" errors unless the json file itself didn't exist).

 

Anyway, this is the code I have:

	public void RegisterItemWithVariants(Item item, String registryname, IMetaLookup variant) {
	super.RegisterItemWithVariants(item, registryname, variant);
	List<ItemStack> list = new ArrayList<ItemStack>();
	item.getSubItems(item, CreativeTabs.SEARCH, list);
	for(ItemStack stack : list) {
		registerItemModelForMeta(item, stack.getMetadata(), variant.getName()+"="+variant.getByOrdinal(stack.getMetadata()).name());
	}
}

 

Where

registerItemModelForMeta

is that same function being used by the blocks that you had in your code and

IMetaLookup

is just an interface wrapper around the enum I'm using so I can convert it back into the variant strings similar to the block's "getPropertyString()" call (I pass in MyEnum.ARBITRARY_VALUE and it's just used to access the lookup methods).

 

(JSON file at the moment is set up with predicate overrides, not variants, so not including it).

 

Is the problem the fact that for the item it's looking at "modid:models/item" for the json file (due to

item.getRegistryName()

and I really need to point it at "modid:blockstates"?

 

TL;DR:

I'm basically scratching my head because I'm getting no feedback when something doesn't work.

  • Quote

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.

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5100 posts
Posted July 20, 2016

I'm not entirely sure what you've done wrong, but you can see my implementation of an item (and its models) with enum-based metadata variants here.

  • Quote

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted July 20, 2016

Yeah, like I said, I'm not sure what I've done wrong either, only that no errors are logged.  I'll digest your code here in a bit.

 

One of the differences is that my enum list isn't going to be used in its entirety: I've got several ore types to deal with, but any given item won't necessarily be valid for all the ore types, e.g. metal nuggets.  I don't need to create a Gold Nugget variant item model because that item is already supplied by vanilla.  That was why I was using item.getSubItems() rather than enum.values; I want to maintain metavalues across several items.

 

Anyway, thanks for the continued help.  Eventually I'll understand how the vanilla systems work well enough to rapidly prototype items like I used to.

  • Quote

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.

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted July 20, 2016

A lot of things

 

Ok, that came down to realizing that you had a custom model defined in an odd spot that I didn't notice right away.  It looked so much like something else that.

 

Urg.  So many things can go wrong with this new system, especially when trying to avoid asset bloat (seriously, vanilla has sixty four models for the clock).  And half of them don't even generate errors.*  Makes me feel like this json model system is built out of magic strings.  Which it kind of is, the problem is that it's not well documented so setting up something is either: do it the painful vanilla way or try to examine the code that parses the json files (I tried and couldn't even locate an entry point that I could follow).

 

That whole "abstractions at their core are lies" thing.

 

[me=Draco18s]archives the project in this state so if he ever needs to do this again, he has it.[/me]

 

*This is probably an exaggeration, but the number of times I've gotten purple squares or outright invisible models without a single logged error is about as many times as I've had errors.

  • Quote

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.

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5100 posts
Posted July 20, 2016

I did link to an explanation of the model loading process in my first reply, you may want to look through the code paths it mentions to see how models are parsed.

  • Quote

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15998 posts
Posted July 20, 2016

I did link to an explanation of the model loading process in my first reply, you may want to look through the code paths it mentions to see how models are parsed.

 

I know. It was a problem of not being able to see every detail that I needed to see.

 

And I'll do that at some point, but not right away.

  • Quote

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.

Share this post


Link to post
Share on other sites
  • Prev
  • 1
  • 2
  • Next
  • Page 2 of 2  

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • cadbane86140
      Minecraft: Parkour Stairs Part 1!

      By cadbane86140 · Posted 38 minutes ago

      Hello There! Today we are playing a BRAND NEW parkour map that was actually just released about a month ago and all I gotta say is that this map is so freaking unique and the map creators did something with this map that we have never seen in parkour before! There are so many hilarious moments in this video that I know you guys are gonna love! I hope you all enjoy this video and if you did don't forget to like and sub for more! https://www.youtube.com/watch?v=5aGkMp5bExg
    • cadbane86140
      Revisiting our 2013 head shop!

      By cadbane86140 · Posted 38 minutes ago

      Hello there! With the recent re release of the old creative server I knew I had to make a video on there. So that is exactly what we did! We did a small tour of our old plot like we did last time but however we remembered some of our old friends and we checked out their old plots too! If you guys want us to do more where we just travel to different plots and talk about them let me know! But I hope you all enjoy this video and if you did don’t forget to like and sub for more videos Like this in the future! https://youtu.be/_m_lViaMlGU
    • kiou.23
      Block Rotate

      By kiou.23 · Posted 1 hour ago

      That's usually the case, always try to understand the code before copy and pasting, or else you'll get a lot of headaches later in the code's life
    • Varzac
      Forge jar file not opening

      By Varzac · Posted 1 hour ago

      I ran Jarfix and then tried installing again with the same results. Nothing happening I even tried using winrar, but as you said nothing happened
    • BeardlessBrady
      [1.16.4] Null when OpenGUI

      By BeardlessBrady · Posted 1 hour ago

      Ah.. Thats what I get for stopping half way through and not double checking, thanks!
  • Topics

    • cadbane86140
      0
      Minecraft: Parkour Stairs Part 1!

      By cadbane86140
      Started 38 minutes ago

    • cadbane86140
      0
      Revisiting our 2013 head shop!

      By cadbane86140
      Started 38 minutes ago

    • ehbean
      10
      Block Rotate

      By ehbean
      Started 7 hours ago

    • Varzac
      3
      Forge jar file not opening

      By Varzac
      Started 14 hours ago

    • BeardlessBrady
      2
      [1.16.4] Null when OpenGUI

      By BeardlessBrady
      Started 2 hours ago

  • Who's Online (See full list)

    • Beethoven92
    • ThisIsNotOriginal
    • Sqsuensay
    • HappyAndJust
    • Funyaah
    • ehbean
    • kiou.23
    • -MCS_Gaming-
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10] Custom ItemBlock class?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community