Jump to content

I'm not able to register model to my item


MGlolenstine

Recommended Posts

2 minutes ago, V0idWa1k3r said:

 

Just now, V0idWa1k3r said:

You have only changed the method name. That does nothing, your method can be called whatever you'd like it to be. To change the lifecycle event(aka loading stage) change the parameter. There is FMLPreInitializationEvent for pre-init, FMLInitializationEvent for init, FMLPostInitializationEvent for post-init and a bunch of others.

Ok, so I changed it, rebuilt it and the problem is persisting:

---- Minecraft Crash Report ----
// Ouch. That hurt :(

Time: 6/27/17 11:50 PM
Description: Initializing game

java.lang.NullPointerException: Initializing game
	at xyz.mglolenstine.SimpleRings.ItemRenderRegister.modelRegister(ItemRenderRegister.java:15)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_0_ItemRenderRegister_modelRegister_ModelRegistryEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
	at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1105)
	at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:762)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:646)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:276)
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:440)
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:352)
	at net.minecraft.client.main.Main.main(SourceFile:124)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Client thread
Stacktrace:
	at xyz.mglolenstine.SimpleRings.ItemRenderRegister.modelRegister(ItemRenderRegister.java:15)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_0_ItemRenderRegister_modelRegister_ModelRegistryEvent.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185)
	at net.minecraftforge.fml.client.FMLClientHandler.fireSidedRegistryEvents(FMLClientHandler.java:1105)
	at net.minecraftforge.fml.common.FMLCommonHandler.fireSidedRegistryEvents(FMLCommonHandler.java:762)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:646)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:276)
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:440)

-- Initialization --
Details:
Stacktrace:
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:352)
	at net.minecraft.client.main.Main.main(SourceFile:124)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
	Minecraft Version: 1.11.2
	Operating System: Linux (amd64) version 4.8.0-53-generic
	Java Version: 1.8.0_131, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 114101568 bytes (108 MB) / 307081216 bytes (292 MB) up to 1060372480 bytes (1011 MB)
	JVM Flags: 5 total; -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.38 Powered by Forge 13.20.0.2366 6 mods loaded, 6 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
	UC	minecraft{1.11.2} [Minecraft] (minecraft.jar) 
	UC	mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) 
	UC	FML{8.0.99.99} [Forge Mod Loader] (forge-1.11.2-13.20.0.2366.jar) 
	UC	forge{13.20.0.2366} [Minecraft Forge] (forge-1.11.2-13.20.0.2366.jar) 
	UC	mercurius_updater{1.0} [mercurius_updater] (MercuriusUpdater-1.11.2.jar) 
	UC	simplerings{0.0.1} [Simple Rings] (modid-1.0.jar) 
	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 375.66' Renderer: 'GeForce 610M/PCIe/SSE2'
	Launched Version: 1.11.2-forge1.11.2-13.20.0.2366
	LWJGL: 2.9.4
	OpenGL: GeForce 610M/PCIe/SSE2 GL version 4.5.0 NVIDIA 375.66, NVIDIA Corporation
	GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

	Using VBOs: Yes
	Is Modded: Definitely; Client brand changed to 'fml,forge'
	Type: Client (map_client.txt)
	Resource Packs: 
	Current Language: English (US)
	Profiler Position: N/A (disabled)
	CPU: 4x Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz

And this is the updated preinit

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e){
  logger = Logger.getLogger(Rings.MODID);
  logger.info("Creating items!");
  ModItems.createItems();
}

 

Link to comment
Share on other sites

1 minute ago, V0idWa1k3r said:

Booted an older project, checked the thing. Apparently in older versions ModelRegistryEvent is fired before pre-init so you can't have your items being created in pre-init. You need to use forge's registry system. Creating your item instances at clinit(public static final Item name = ...) 'should' work but is not advised. Haven't tested that.

Well... IMO the Docs are not written very well. No offense to whoever wrote them, but I'm just not satisfied with "Setting the properties of an item as above only works for simple items. If you want more complicated items, you should subclass Item and override its methods." But anyways... Could you please give me an example or explain to me what clinit is?

Link to comment
Share on other sites

clinit is a way to say "class init", when all static things are set and the static block is fired alltogether. Practicaly what I'm saying is "define your item as public static final Item item = new WoodenRing(yourparams) and when your class is constructed the item will be initialized aswell".

The docs are being worked on right now, I think. Apart from that they are open-sourced and if you do not like the spelling you are free to change it and submit a PR. Or an issue. Considering that the docs were written for modders in the first place...

Anyway the registry system is pretty simple, actually. I'll link you an example in a minute and I'll edit this post when I'll do.

 

EDIT: here(and fields) is an example. This is actually somewhat not the way you are supposed to do it now, but I am not sure if the way to do it now will work in whatever version you are developing for. You should still keep the 'latest' way to do it in mind though.

Edited by V0idWa1k3r
Link to comment
Share on other sites

....Alternatively, use ModelLoader in preInit...

  • Like 1

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

1 minute ago, Draco18s said:

....Alternatively, use ModelLoader in preInit...

Will try that as well.

 

4 minutes ago, V0idWa1k3r said:

clinit is a way to say "class init", when all static things are set and the static block is fired alltogether. Practicaly what I'm saying is "define your item as public static final Item item = new WoodenRing(yourparams) and when your class is constructed the item will be initialized aswell".

The docs are being worked on right now, I think. Apart from that they are open-sourced and if you do not like the spelling you are free to change it and submit a PR. Or an issue. Considering that the docs were written for modders in the first place...

Anyway the registry system is pretty simple, actually. I'll link you an example in a minute and I'll edit this post when I'll do.

Thanks! I hope that docs will be finished soon. It wasn't the problem with spelling or anything like that, I just think that some of the things are a little vague, which I found disturbing.

Link to comment
Share on other sites

I hope that I'm not dreaming, because it's 00:21 right now, but I think it's still not working. Take a look at the picture.

Current preInit code:

@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e){
	logger = Logger.getLogger(Rings.MODID);
	logger.info("Creating items!");
	ModItems.createItems();
	ModelLoader.setCustomModelResourceLocation(ModItems.wring, 0, new ModelResourceLocation(ModItems.wring.getRegistryName(), "inventory"));
}

 

Screenshot from 2017-06-28 00-20-35.png

EDIT: Log:

[00:19:34] [Client thread/ERROR] [FML]: Exception loading model for variant simplerings:wooden_ring#inventory, normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model simplerings:item/wooden_ring with loader VanillaLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.func_177590_d(ModelLoader.java:340) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.func_177577_b(ModelBakery.java:175) ~[cbk.class:?]
	at net.minecraftforge.client.model.ModelLoader.func_177570_a(ModelLoader.java:160) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.func_110549_a(ModelManager.java:28) [cbl.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.func_110542_a(SimpleReloadableResourceManager.java:122) [cae.class:?]
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:500) [bes.class:?]
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:352) [bes.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:124) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
Caused by: java.io.FileNotFoundException: simplerings:models/item/wooden_ring.json
	at net.minecraft.client.resources.SimpleReloadableResourceManager.func_110536_a(SimpleReloadableResourceManager.java:69) ~[cae.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.func_177594_c(ModelBakery.java:334) ~[cbk.class:?]
	at net.minecraftforge.client.model.ModelLoader.access$1600(ModelLoader.java:127) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:941) ~[ModelLoader$VanillaLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
	... 14 more
[00:19:34] [Client thread/ERROR] [FML]: Exception loading model for variant simplerings:wooden_ring#inventory, blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model simplerings:wooden_ring#inventory with loader VariantLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.func_177590_d(ModelLoader.java:348) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.func_177577_b(ModelBakery.java:175) ~[cbk.class:?]
	at net.minecraftforge.client.model.ModelLoader.func_177570_a(ModelLoader.java:160) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.func_110549_a(ModelManager.java:28) [cbl.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.func_110542_a(SimpleReloadableResourceManager.java:122) [cae.class:?]
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:500) [bes.class:?]
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:352) [bes.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:124) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_131]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.func_188004_c(ModelBlockDefinition.java:78) ~[brj.class:?]
	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1257) ~[ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
	... 14 more

 

Edited by MGlolenstine
Added latest log
Link to comment
Share on other sites

4 minutes ago, V0idWa1k3r said:

That is an issue we'll need a log for

Edited!^

 

EDIT: I think I misplaced wooden_ring.json, because I don't know where to put it (Forge docs again...)

 

My current project structure:

 

Screenshot from 2017-06-28 00-29-20.png

Edited by MGlolenstine
added my opinion
Link to comment
Share on other sites

Well the log says:

9 minutes ago, MGlolenstine said:

Caused by: java.io.FileNotFoundException: simplerings:models/item/wooden_ring.json

Is there an actual file at that location(src/main/resources/assets/simplerings/models/item/wooden_ring.json) or a blockstates file at src/main/resources/assets/simplerings/blockstates/wooden_ring.json with an inventory variant defined? You'll need either of the two.

 

Edit: yeah, your item model file must be located at src/main/resources/assets/simplerings/models/item/

Edited by V0idWa1k3r
Link to comment
Share on other sites

1 minute ago, V0idWa1k3r said:

Well the log says:

Is there an actual file at that location(src/main/resources/assets/simplerings/models/item/wooden_ring.json) or a blockstates file at src/main/resources/assets/simplerings/blockstates/wooden_ring.json with an inventory variant defined? You'll need either of the two.

Ok, so I moved my wooden_ring.json to the first location. Where should I put wooden_ring.png to?

Link to comment
Share on other sites

The way it is defined in your model file right now it would actually be  src/main/resources/assets/simplerings/textures/textures/wooden_ring.json.

You probably want to change the way you define your texture in your model file. Basically the path will be src/main/resources/assets/%modid%/textures/%path%.png. So a path like "simplerings:items/wooden_ring" will lead to a location of src/main/resources/assets/simplerings/textures/items/wooden_ring.png

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

The way it is defined in your model file right now it would actually be  src/main/resources/assets/simplerings/textures/textures/wooden_ring.json.

You probably want to change the way you define your texture in your model file. Basically the path will be src/main/resources/assets/%modid%/textures/%path%.png. So a path like "simplerings:items/wooden_ring" will lead to a location of src/main/resources/assets/simplerings/textures/items/wooden_ring.png

Aha... Thanks for explanation!

Link to comment
Share on other sites

9 minutes ago, V0idWa1k3r said:

The way it is defined in your model file right now it would actually be  src/main/resources/assets/simplerings/textures/textures/wooden_ring.json.

You probably want to change the way you define your texture in your model file. Basically the path will be src/main/resources/assets/%modid%/textures/%path%.png. So a path like "simplerings:items/wooden_ring" will lead to a location of src/main/resources/assets/simplerings/textures/items/wooden_ring.png

I only have one more question and I don't think it's worth opening a new thread. How can I rename my item? Even tho I have

this.setUnlocalizedName();

set in the constructor function, the name persists as "simplerings:wooden_ring#inventory"

Link to comment
Share on other sites

Just now, MGlolenstine said:

this.setUnlocalizedName();

setUnlocalizedName requires a string as a parameter. That string will be the unlocalized name of the item. If you mean the registry name then it is Item::setRegistryName for that, but that is something you set once and never change.

2 minutes ago, MGlolenstine said:

the name persists as "simplerings:wooden_ring#inventory"

That is not a name, that is a ModelResourceLocation. Please clarify what you mean by "the name persists"

Link to comment
Share on other sites

3 minutes ago, V0idWa1k3r said:

setUnlocalizedName requires a string as a parameter. That string will be the unlocalized name of the item. If you mean the registry name then it is Item::setRegistryName for that, but that is something you set once and never change.

That is not a name, that is a ModelResourceLocation. Please clarify what you mean by "the name persists"

Yes, I've made a mistake, I'm running my construction method like this

public WoodenRing(String registryName, String unlocalizedName, int MaxStackSiz){
    super();
    this.setRegistryName(registryName);
    this.setUnlocalizedName(unlocalizedName);
    this.setCreativeTab(CreativeTabs.REDSTONE);
    this.setMaxStackSize(MaxStackSize);
}

But when I call it with

GameRegistry.register(wring = new WoodenRing("wooden_ring", "Wooden ring", 1));

item's name is still registry name...

Screenshot from 2017-06-28 00-54-51.png

Edited by MGlolenstine
Link to comment
Share on other sites

That should not be the case if by 'item's name' you mean "unlocalized name I see in the game". How do you know that the game uses the registry name as the unlocalied name? That should not be possible. In the game you should see item.wooden ring.name as the name of your item. If it would be using your registry name you would see item.simplerings:wooden_ring.name in the game when mousing over the item.

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

That should not be the case if by 'item's name' you mean "unlocalized name I see in the game". How do you know that the game uses the registry name as the unlocalied name? That should not be possible. In the game you should see item.wooden ring.name as the name of your item. If it would be using your registry name you would see item.simplerings:wooden_ring.name in the game when mousing over the item.

I've updated the question with a picture, and yeah, so how can I replace that name with "Wooden Ring"?

Link to comment
Share on other sites

Just now, V0idWa1k3r said:

That is what you use language files for. The item.%unlocalizedName%.name is your key and whatever you want to see is your value. See how vanilla structures it's language files for more info

Ahh... Ok thank, I thought that I had to change it's name via the code.

Link to comment
Share on other sites

You should also be using the registry name as the unlocalized name to avoid conflicts with other mods.

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

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.