Jump to content

[1.8] item rendering not working


sigurd4

Recommended Posts

this is very strange. i've been struggling for days now trying to figure this out on my own. there's been a lot of other posts with the excact same problem, and i've tried doing the same thing that solved it for those, but it wont work. i've quadruple-checked that the path is correct and i've tried making a new world. none of it works. previously in the log it said it couldnt find the json file, but i fixed it, and now it doesn't say anything special. despite that, the item looks like a untextured block, except double the size of a normal block (more or less), which i've noticed is a common issue. hwever, i've tried every single solution i've found and none of it has worked for me. main mod file code:

 

main mod class:

@Mod(modid = References.MODID, version = References.VERSION)
public class M
{
//TODO if we are ever going to add mobs, enable this and notify me! i have some nifty code for custom mob eggs that we can use! - sigurd4
/**Register entity with egg**/
/*public static void registerEntity(Class<? extends Entity> entityClass, String name, int entityID, int primaryColor, int secondaryColor)
{
	EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
	ItemMonsterPlacer2.EntityList2.registerEntity(entityClass, entityID, name, primaryColor, secondaryColor);
}*/

/**Register entity without egg**/
public static void registerEntityNoEgg(Class<? extends Entity> entityClass, String name, int entityID)
{
	EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 1, true);
}

@Instance(References.MODID)
public static M instance;

public static SimpleNetworkWrapper network;

/**tabs**/
public static TabGeneric tabCore = new TabGeneric("spectralGunsCore", M.component_barrel);
/**items**/
public static ItemComponent component_barrel;

public M()
{
	items();
	tabs();
}

private void items()
{
	component_barrel = (ItemComponent)new ItemComponent("barrel").setUnlocalizedName("barrel");
}

private void tabs()
{
	tabCore.icon = component_barrel;
}

@SidedProxy(clientSide = References.Client, serverSide = References.Server)
public static ProxyCommon proxy;

@EventHandler
public void init(FMLInitializationEvent event)
{
	proxy.init();
}
}

 

the reason there are so many comments is because im working with some other people, so i need to explain stuff for them.

 

modid in References is "spectralguns"

 

client proxy:

public class ProxyClient extends ProxyCommon
{
@Override
public void init()
{
	super.init();

	/**to be used for item rendering**/
	RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
	/**to be used for item rendering**/
	RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();

	MinecraftForge.EVENT_BUS.register(new HandlerClient());
	FMLCommonHandler.instance().bus().register(new HandlerClientFML());

	//TODO add keyhandler
	//HandlerKeys.init();
	//FMLCommonHandler.instance().bus().register(new HandlerKeys());
}
}

client fml event handler:

@SideOnly(Side.CLIENT)
public class HandlerClientFML extends HandlerCommonFML
{
//fml events for client only here!

@EventHandler
public void FMLInitializationEvent(FMLInitializationEvent event)
{
	Minecraft mc = Minecraft.getMinecraft();
	RenderItem ri = mc.getRenderItem();
	ItemModelMesher imm = ri.getItemModelMesher();
	for(int i = 0; i < ItemBase.itemsToBeRegistered.size(); ++i)
	{
		ItemBase item = ItemBase.itemsToBeRegistered.get(i);
		imm.register(item, 0, new ModelResourceLocation(References.MODID + ":" + item.id, "inventory"));
	}
}
}

ItemBase class:

public abstract class ItemBase extends Item
{
public static ArrayList<ItemBase> itemsToBeRegistered = new ArrayList<ItemBase>();

public final String id;
private CreativeTabs[] creativeTabs;

public static final String RIGHTCLICKED = "RightClicked";
/**
 * Base for all items
 */
public ItemBase(String id)
{
	super();
	this.setMaxStackSize(64);
	GameRegistry.registerItem(this, id);
	itemsToBeRegistered.add(this);
	this.id = id;
}

/**
 * Base for all items
 */
public ItemBase(String id, CreativeTabs[] tabs)
{
	this(id);
	this.setCreativeTabs(tabs);
}

/**
 * Gets a list of tabs that items belonging to this class can display on,
 * combined properly with getSubItems allows for a single item to span
 * many sub-items across many tabs.
 *
 * @return A list of all tabs that this item could possibly be on.
 */
@Override
public CreativeTabs[] getCreativeTabs()
{
	if(this.creativeTabs != null)
	{
		return  this.creativeTabs;
	}
	else
	{
		return super.getCreativeTabs();
	}
}

public void setCreativeTabs(CreativeTabs[] tabs)
{
	this.creativeTabs = tabs;
}
}

ItemComponent class:

public class ItemComponent extends ItemBase
{
/**
 * Crafting components
 */
public ItemComponent(String id)
{
	super("component_" + id);
	this.setCreativeTab(M.tabCore);
}

/**
 * Crafting components
 */
public ItemComponent(String id, CreativeTabs[] tabs)
{
	super("component_" + id, tabs);
}

    public Item setUnlocalizedName(String unlocalizedName)
    {
        return super.setUnlocalizedName("component." + unlocalizedName);
    }
}

component_barrel.json in spectralguns:models/item:

{
    "parent": "builtin/generated",
    "textures": {
        "layer0": "spectralguns:items/barrel"
    },
    "display": {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.7, 1.7, 1.7 ]
        }
    }
}

texture is spectralguns:textures/items/barrel.png

 

i cant find out what i've done wrong! there are so many things in 1.8 that confuse me and this especially. :/

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Link to comment
Share on other sites

ok i tried something different, but it's not working:

client fml event handler:

@SideOnly(Side.CLIENT)
public class HandlerClientFML extends HandlerCommonFML
{
//fml events for client only here!

@EventHandler
public void FMLInitializationEvent(FMLInitializationEvent event)
{
	Minecraft mc = Minecraft.getMinecraft();
	RenderItem ri = mc.getRenderItem();
	ItemModelMesher imm = ri.getItemModelMesher();
	for(int i = 0; i < ItemBase.itemsToBeRegistered.size(); ++i)
	{
		ItemBase item = ItemBase.itemsToBeRegistered.get(i);
		//String id = References.MODID + ":" + item.id;
		String id = References.MODID + ":" + item.getUnlocalizedName2();
		ModelBakery.addVariantName(item, new String[]{id});
		imm.register(item, 0, new ModelResourceLocation(id, "inventory"));
	}
}
}

getUnlocalizedName2() in ItemBase:

public String getUnlocalizedName2()
{
	String s = getUnlocalizedName();
	s = s.replaceFirst("item.", "");
	return s;
}

now i get the warning in the console saying it cant find the json file. you sure it doesn't use the item string id rather than the unlocalized name?

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Link to comment
Share on other sites

[14:57:43] [Client thread/WARN]: Unable to load item model: 'spectralguns:item/component_barrel' for item: 'spectralguns:component_barrel'
java.io.FileNotFoundException: spectralguns:models/item/component_barrel.json
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:70) ~[FallbackResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadModel(ModelBakery.java:260) ~[ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadItemModels(ModelBakery.java:307) [ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadVariantItemModels(ModelBakery.java:105) [ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelBakery.setupModelRegistry(ModelBakery.java:88) [ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:727) [Minecraft.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:298) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:484) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:325) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_25]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_25]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]

it's the same name that i used previously. the strange thing is that it does not seem to be affected by the string i use in the json file registration in my event handler. it seems to use the item's string id instead. do i even need to register it like i have done; in the init event?

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Link to comment
Share on other sites

This is the basic code that I was working with:

 

    	obliteratorAxe = new ItemAxeUpgrade(Item.ToolMaterial.EMERALD);
    	obliteratorAxe.setUnlocalizedName("obliteratorAxe");
    	GameRegistry.registerItem(obliteratorAxe, "obliteratorAxe");
    	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(obliteratorAxe, 0, new ModelResourceLocation("perstools:obliteratorAxe", "inventory"));

 

I'm going to keep looking over your code to see if I can locate the issue, but from what I understand, the unlocalized name as well as the ModelResourceLocation have to be the same (other than the modID in front of the ":". Sorry if I'm wrong, but that seems to have been my initial issue. My unlocalized name was different.

 

Just want to make sure,

your model json is located here? - src/main/resources/assets/spectralguns/models/item

And the name of the file is "component_barrel.json"

Also respecting all letter cases.

Link to comment
Share on other sites

yes exactly.

also, i notice that your unlocalizedName is the same as the item string id, so that makes sense.

another thing: i /* */ed out the whole model registering stuff and it seemed to still look after the model. isn't that strange? do i actually need to register the item like that? the string i put in the register code does not seem to affect anything. then i tried changing the unlocalizedName to match the id, yet i have the same problem (yes, i tried making a new world).

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

Link to comment
Share on other sites

I don't know what to tell you... I used the code that you put in your initial post, and I recreated it in my workspace. When I started the game, the image loaded up fine right away... Do you get the "java.io.FileNotFoundException: spectralguns:models/item/component_barrel.json" error with the code in your initial post?

 

Also, if you open up the file directory where your json is saved, is it located here?

 

"WhereverYouSavedYourModdingFolder"\fml\src\main\resources\assets\spectralguns\models\item

 

As a last ditch effort, maybe try to "Clean" your workspace? I don't know what tool you use, but with Eclipse, it can be found under "Project" - "Clean". This should clear out any temp files that could be causing issues...

 

Good Luck with this...

Link to comment
Share on other sites

I don't know what to tell you... I used the code that you put in your initial post, and I recreated it in my workspace. When I started the game, the image loaded up fine right away... Do you get the "java.io.FileNotFoundException: spectralguns:models/item/component_barrel.json" error with the code in your initial post?

no. i did when i changed the name of the json file. if i changed the string in the texture registration thing it didnt change anything.

 

Also, if you open up the file directory where your json is saved, is it located here?

 

"WhereverYouSavedYourModdingFolder"\fml\src\main\resources\assets\spectralguns\models\item

fml? ok i moved my src folder into a new folder that i named fml and made it like you described, then added \fml\src\main\resources and \fml\src\main\java to the build path. didn't do any difference.

 

As a last ditch effort, maybe try to "Clean" your workspace? I don't know what tool you use, but with Eclipse, it can be found under "Project" - "Clean". This should clear out any temp files that could be causing issues...

will try this. i'll come back once i've done it.

 

Good Luck with this...

thanks. this update has been a lot of trouble for me. hopefully it'll work after i clean my workspace.

 

Maybe try "refreshing" your eclipse workspace by pressing F5? For me, usually, any changes I do to the texture JSON files won't apply in eclipse (and in-game) until I refresh.

done that for a long time ago.

http://www.planetminecraft.com/member/sigurd4

I'm making the bioshock mod!

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.