Jump to content

Recommended Posts

Posted

I've been looking over the forge documentation for adding models and textures to items in 1.12.2, and I feel like it's not really giving me a clear answer. I'm making a test item to see if it would work so I can add crafting components to my mod with no special abilities of their own. I scroll down to the item part of this page, and look over the instructions three times, and it still isn't clear. Can someone help me figure this out?

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

I do that and it gives me an error with the .@GameRegistry.ObjectHolder line in my code. Heres what the code for the ModItems class looks like:

package net.overgrownportal.item;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ModItems{
	
    //gives me error on the line below...
    @GameRegistry.ObjectHolder("overgrownportal:itemlightbridge")
    public static ItemLightBridge itemLightBridge;

    @SideOnly(Side.CLIENT)
    public static void initModels() {
        itemLightBridge.initModel();
    }
}

And the code for the item:

package net.overgrownportal.item;

import net.minecraft.item.Item;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.overgrownportal.mod.OvergrownPortal;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.SimpleTexture;
import net.minecraft.creativetab.*;

public class ItemLightBridge extends Item{
	public ItemLightBridge() {
        setRegistryName("hardlightbridge");
        setUnlocalizedName(OvergrownPortal.MODID + ".hardlightbridge");
    }

    @SideOnly(Side.CLIENT)
    public void initModel() {
        ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    }
}

 

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted
  On 7/25/2018 at 5:44 PM, Animus_Surge said:

Can someone help me figure this out?

Expand  

Simply put you need an item instance so new Item(...). Then you need to subscribe to the RegistryEvent.Register<Item> and register your item. Then subscribe to ModelRegistryEvent and call ModelLoader.setCustomModelResourceLocation(yourItemInstance, the metadata, and then the model location). The model location is a ModelResourceLocation. Typically it is instantiated by passing in your items registry name and then a string called inventory.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Objectholder takes the registry name, in yours they do not match.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted
  On 7/25/2018 at 6:17 PM, DaemonUmbra said:

Objectholder takes the registry name, in yours they do not match.

Expand  

Can you tell me how to make them match?

 

 

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted (edited)

Simply use the String you typed in in setRegistryName() after your modid in your case hardlightbridge

So complete it would be modid:registryName

Edited by _Cruelar_

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Posted

It looks like this now:
 

package net.overgrownportal.item;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ModItems{

    @GameRegistry.ObjectHolder("overgrownportal:hardlightbridge")
    public static ItemLightBridge itemLightBridge;

    @SideOnly(Side.CLIENT)
    public static void initModels() {
        itemLightBridge.initModel();
    }
		
}

but it still gives me the same error

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted (edited)

and I forget to change the modid from the original when I got the MDK for 1.12.2. So that explains the mismatch with the modid, but still the same error

 

Edited by Animus_Surge
did not fix the error after all...

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted

Do you register it some where with this:

event.getRegistry().register(new Triforce());

(Triforce is a normal Item in my mod)

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Posted
  On 7/25/2018 at 6:34 PM, Animefan8888 said:

Do you have the import?

Expand  

I do

 

I fixed it by looking through the net.minecraftforge.fml.common.registry package, so I have no code errors anymore. The ModItems class now looks like this:

package net.overgrownportal.item;

import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class ModItems{

    @GameRegistry.ObjectHolder("overgrownportal:hardlightbridge")
    public static ItemLightBridge itemLightBridge;

    @SideOnly(Side.CLIENT)
    public static void initModels() {
        itemLightBridge.initModel();
    }
		
}

so now I need to figure out how to call on the itemlightbridge.json file.

 

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted
  On 7/25/2018 at 6:36 PM, Animus_Surge said:

so now I need to figure out how to call on the itemlightbridge.json file.

Expand  

Well, you have an initModels method. Are you calling it from anywhere?

Also, please do not go marking methods with @SideOnly unless you know what you are doing

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

Simply insert the json at the right place, it should work then.

BTW: Is this a Portalgun expansion of a kind. Like adding lightbridges, fizzlers etc.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Posted
  On 7/25/2018 at 6:36 PM, Animus_Surge said:

so now I need to figure out how to call on the itemlightbridge.json file.

Expand  

If you use 

ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(getRegistryName(),...) then it will look for a file at assets/modid/models/item/registryname.json

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 7/25/2018 at 6:39 PM, _Cruelar_ said:

Simply insert the json at the right place, it should work then.

BTW: Is this a Portalgun expansion of a kind. Like adding lightbridges, fizzlers etc.

Expand  

pretty much, because IDK when the real mod's fizzler will come back and that actually works in the newer versions

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted
  On 7/25/2018 at 6:40 PM, Animefan8888 said:

If you use 

ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(getRegistryName(),...) then it will look for a file at assets/modid/models/item/registryname.json

Expand  

what do I replace "meta" with?

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

Posted (edited)

The ObjectHolder annotation is described on this page of the Forge Documentation, please read it.

Also your registry name setup right now is broken, I recommend

setRegistryName(MODID,"ItemName")

otherwise using getRegistryName() within setCustomModelResourceLocation() will be telling Minecraft to look within itself for your model files.

It appears I am behind the times.

Edited by DaemonUmbra

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted
  On 7/25/2018 at 6:40 PM, Animus_Surge said:

pretty much, because IDK when the real mod's fizzler will come back and that actually works in the newer versions

Expand  

I think the fizzlers wil never come. As I know the mod is dead/in a zombie-like state getting only ported to new versions.

I would really like to see the things out of 1.7.10 Portalgun mod into 1.12.2 or 1.13.

 

  On 7/25/2018 at 6:43 PM, DaemonUmbra said:

The ObjectHolder annotation is described on this page of the Forge Documentation, please read it.

Also your registry name setup right now is broken, I recommend

setRegistryName(MODID,"ItemName")

otherwise using getRegistryName() within setCustomModelResourceLocation() will be telling Minecraft to look within itself for your files.

Expand  

Wait why broken? I use it quite the same way and he registers it as stuff of my mod.

My Projects:

Cruelars Triforcemod (1.12 release; 1.14 alpha soon coming)

 

Important:

As my mod is on at least 10 different third party sites without my permission, I want to warn you about that with a link to StopModReposts

Posted
  On 7/25/2018 at 6:42 PM, Animus_Surge said:

what do I replace "meta" with?

Expand  

In your case 0, but some items have a magical number that allows you to differentiate between different states, or in some cases a "new item".

Also dont disregard the advice of the other people especially DaemonUmbra. They know what they are talking about a lot of the time.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
  On 7/25/2018 at 6:43 PM, DaemonUmbra said:

otherwise using getRegistryName() within setCustomModelResourceLocation() will be telling Minecraft to look within itself for your files.

Expand  

This isn't true forge will automatically append your mods modid as long as it is your mod that it is constructing, aka dont use static initializers.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted (edited)

Checking the GitHub it looks like that's relatively new, I did not know that was a thing.

Edit: Nope I'm just a massive derp, I could've sworn I had an issue with this in the past.

Edited by DaemonUmbra

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted

No code errors after fixing a bunch of errors, and my game crashes with the following:

[15:00:09] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: ---- Minecraft Crash Report ----
// Shall we play a game?

Time: 7/25/18 3:00 PM
Description: Initializing game

java.lang.NullPointerException: Initializing game
	at net.minecraftforge.client.model.ModelLoader.setCustomModelResourceLocation(ModelLoader.java:1090)
	at net.overgrownportal.item.ItemLightBridge.<init>(ItemLightBridge.java:19)
	at net.overgrownportal.mod.CommonProxy.registerItems(CommonProxy.java:16)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_CommonProxy_registerItems_Register.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:757)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:246)
	at net.minecraft.client.Minecraft.init(Minecraft.java:513)
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)


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

-- Head --
Thread: Client thread
Stacktrace:
	at net.minecraftforge.client.model.ModelLoader.setCustomModelResourceLocation(ModelLoader.java:1090)
	at net.overgrownportal.item.ItemLightBridge.<init>(ItemLightBridge.java:19)
	at net.overgrownportal.mod.CommonProxy.registerItems(CommonProxy.java:16)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_CommonProxy_registerItems_Register.invoke(.dynamic)
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:757)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:246)
	at net.minecraft.client.Minecraft.init(Minecraft.java:513)

-- Initialization --
Details:
Stacktrace:
	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
	at net.minecraft.client.main.Main.main(Main.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
	at GradleStart.main(GradleStart.java:25)

-- System Details --
Details:
	Minecraft Version: 1.12.2
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_172, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 746705472 bytes (712 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)
	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
	FML: MCP 9.42 Powered by Forge 14.23.4.2739 7 mods loaded, 7 mods active
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

	| State | ID              | Version      | Source                           | Signature |
	|:----- |:--------------- |:------------ |:-------------------------------- |:--------- |
	| UCH   | minecraft       | 1.12.2       | minecraft.jar                    | None      |
	| UCH   | mcp             | 9.42         | minecraft.jar                    | None      |
	| UCH   | FML             | 8.0.99.99    | forgeSrc-1.12.2-14.23.4.2739.jar | None      |
	| UCH   | forge           | 14.23.4.2739 | forgeSrc-1.12.2-14.23.4.2739.jar | None      |
	| UCH   | overgrownportal | 1.0          | bin                              | None      |
	| UCH   | ichunutil       | 7.0.2        | iChunUtil-1.12.2-7.0.2.jar       | None      |
	| UCH   | portalgun       | 7.0.2        | PortalGun-1.12.2-7.0.2.jar       | None      |

	Loaded coremods (and transformers): 
	GL info: ' Vendor: 'Intel' Version: '4.5.0 - Build 22.20.16.4836' Renderer: 'Intel(R) HD Graphics 620'
	Launched Version: 1.12.2
	LWJGL: 2.9.4
	OpenGL: Intel(R) HD Graphics 620 GL version 4.5.0 - Build 22.20.16.4836, Intel
	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) i5-7200U CPU @ 2.50GHz
[15:00:09] [main/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:629]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\swag100107\Desktop\forge 1.12.2\run\.\crash-reports\crash-2018-07-25_15.00.09-client.txt

 

Forge 1.8.9 and below are not supported in the forums anymore. Please upgrade to a later version.

 

My experimental mod: new GitHub page to be created... (Add your favorite TCGs in MC! [WIP])

 

When asking for assistance with modding or making mods, paste the log (located in .minecraft/logs folder for mod users or in the console for mod makers).

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.