Jump to content

Recommended Posts

Posted (edited)

So I have an item registered in the game, and have a class ItemRenderRegister to register the item to a modelresource location via the following code:

Spoiler

public class ItemRenderRegister {
	public static void registerItemRenderer() {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ModItems.oldTome, 0, new ModelResourceLocation("ds:oldtome", "inventory"));

	}

the method is called in the client proxy

but I can't wrap my head around how to use the ModelResourceLocation. I'm getting no errors about a missing json file, the item just simply has not model or texture, which makes it very hard to debug. 

Edited by GooberGunter
Posted

I'm no expert, I have just posted my own problem, but I would suggest checking your directory eg: make sure there is an assets folder, make sure the .json is valid etc, take my advice with a grrain of salt though as i said I'm no expert

Posted (edited)

        ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation("ds:models//item//old_tome.json", "inventory"));
 

still not working

 

Spoiler

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "ds:items/old_tome"
    }
}

 And I'm not any errors in the log about the texture location so I know that's right. It's just this part. And I also had a problem where I made two instances of the item, registering one and registering the render of the other, which I have fixed.

Edited by GooberGunter
Posted

You should use items/blocks getRegistryName() as the first parameter.
First parameter should not contain any extensions (".json") nor any file-separators ("/"). All of that is automagically done "behind the curtains" for you.

  • Like 1

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted (edited)

That was suggested in the documentation but i didn't see it in the source code, but I fixed it now. I also added the first parameter, but it's still not showing up

		ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation(ModItems.oldTome.getRegistryName(), "ds:old_tome"));

Am i supposed to register the render or is the model loader enough?

 

Here is all the code involving the item:

 

ModItems:

Spoiler

package com.GooberGunter.DivineSorcery.common.items;

import java.rmi.registry.Registry;

import com.GooberGunter.DivineSorcery.DSReferences;
import com.GooberGunter.DivineSorcery.common.utils.Util;

import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public final class ModItems {
	
	public static Item oldTome = new ItemOldTome("old_tome");
	
	@Mod.EventBusSubscriber
	public static class ItemRegister{
		
		@SubscribeEvent
	    public static void registerItem(RegistryEvent.Register<Item> e) {
	    	e.getRegistry().register(oldTome);
	    	Util.logger.info("ITEMS REGISTERED");
	    }//Items MUST MUST MUST MUST MUST BE REGISTERED IN STATIC FIELDS
	}
}

 

ItemRegisterRender:

Spoiler

package com.GooberGunter.DivineSorcery.client.render.items;

import java.io.FileNotFoundException;
import java.io.IOException;

import com.GooberGunter.DivineSorcery.DSReferences;
import com.GooberGunter.DivineSorcery.common.items.ModItems;
import com.GooberGunter.DivineSorcery.common.utils.Util;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelBakery;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;

public class ItemRenderRegister {
	public static void registerItemRenderer() {
		ModelLoader.setCustomModelResourceLocation(ModItems.oldTome, 0, new ModelResourceLocation(ModItems.oldTome.getRegistryName(), "ds:old_tome"));
		Util.logger.info("Item Renders Registered");
	}
}

 

 

Edited by GooberGunter
Posted (edited)

...

The second parameter is the variant of which you want to use... Unless otherwise specified in the BlockState file, there is only "inventory" for items, but blocks also have "normal" (placed)...

The Item's RegistryName (which comes from getRegistryName()) should already equal "ds:old_tome", IF you used setRegistryName("old_tome") in the item's constructor... You don't need to worry about that...
On a tangent however, modid's are recommended to never be shortened or otherwise altered from the original "name". I don't know what "ds" stands for, but for example, what if I made a mod called "Deep Storage" and also used "ds" as my modid? The longer a modid is, the probability of another mod having the same name exponentially becomes smaller.

 

You also need to actually have this code RUN during the ModelRegistryEvent...

You can do this very simply by annotating your client-proxy with @Mod.EventBusSubscriber and moving your registerItemRenderer method to said client-proxy. Your registerItemRenderer() also needs to become registerItemRenderer(ModelRegistryEvent event), so that the method can be picked up by the scanner, and called when the ModelRegistryEvent is fired, which then will run the code.

Edited by Matryoshika

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted (edited)

Thanks a lot for the tips. Man, it seems like everything was replaced with annotations

 

So to be clear, the render register no longer goes in the init? What are the initialization methods for?

 

Now I'm getting a file not found exception, I've been waiting for one. I have a lead.

 

Edit: classic blockstate, I fixed the chain and now I have the item model json, the blockstate json, and the texture. Everything works fine now

 

 

Do recipes, world generators, and entities still initialize the same or are they events too?

Edited by GooberGunter
Posted
2 hours ago, GooberGunter said:

Do recipes, world generators, and entities still initialize the same or are they events too?

 

Recipes and entities are managed by registries, so register them in RegistryEvent.Register<IRecipe> and RegistryEvent.Register<EntityEntry> respectively. Use EntityEntryBuilder to create the EntityEntry.

 

World Generators aren't managed by a registry and there's no dedicated event to register them, so do it in preInit/init/postInit.

  • Like 1

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.