Jump to content

Recommended Posts

Posted

I've got my Blocks working properly, as blocks, in my inventory, in my hand, on the ground, whatever. They're great.

 

What I can't seem to get working is my regular old Items, and it's driving me batty. I have a metadata item (each state should have a different JSON and texture), but I also have several normal items, and none of them are working.

 

So, first things first, given the following resource setup for one of my simple items, what do I need to pass to the ItemModelMesher? If I get this figured out, I can probably puzzle out everything else, but I'm clearly doing something fundamentally wrong.

 

So.

 

My ModID is animalsdropbones  (legacy, I'll end up refactoring it later)

My slegehammer model is in assets\animalsdropbones\models\item\Stone_Sledgehammer.json

It's code is as such:

 

{
"parent": "builtin/generated",
"textures": {
	"layer0": "animalsdropbones:items/Stone_Sledgehammer"
},
"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]
	}
}
}

 

 

and my texture is in assets\animalsdropbones\textures\items\Stone_Sledgehammer.png

 

Right now I'm doing

ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
mesher.register((Item)item, metadata, new ModelResourceLocation("animalsdropbones:Stone_Sledgehammer"));

 

What's wrong?

Posted

What do you mean by not working? The items show up in game but have pink-black checkered model? Or they don't show up at all?

 

Are you sure your item's unlocalized name matches? "Stone_Sledgehammer". Can you post code for the item as well as the code where you register the item (the item itself, not the item renderer)?

 

Also, I think unlocalized names should be all lower case, so you might want to see if that helps.

 

Otherwise, I can't see anything wrong -- you understand what is needed and it looks correct.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Sorry, I should have been more specific: they show up in game with the pink and black checkered box. They all work in the sense that I can use them in game appropriately, but they're using the default model and texture.

 

 

This is how I instantiate the object:

ToolSledgehammer sledgehammerStone = new ToolSledgehammer(ToolMaterial.STONE);
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
mesher.register((Item)item, metadata, new ModelResourceLocation("animalsdropbones:Stone_Sledgehammer"));

The object registers itself in the constructor. It builds its own name and unlocalized name based on the tool material. I want it to also register itself with the mesher, but I'm not worrying about that yet until I figure out HOW to.

 

This is the tool constructor:

 

/* includes omitted for brevity */
public class ToolSledgehammer extends ItemPickaxe implements IItemName {
    static Random r = new Random();
    private String name = "Sledgehammer"; 
    
public ToolSledgehammer(ToolMaterial material) {
	super(material);
	String materialName = NamespaceManager.capitalizeWord(material.toString()) ;
	name = materialName +"_Sledgehammer";
	setUnlocalizedName( NamespaceManager.getUnLocalized(getName()) );
	this.setCreativeTab(CreativeTabs.tabTools);
        this.setMaxDamage(material.getMaxUses()*4);

        this.efficiencyOnProperMaterial = material.getEfficiencyOnProperMaterial()/4;
        

	GameRegistry.registerItem(this, getName());
}
      /* special tool functionality here, event handling etc. omitted for brevity */
}

 

 

and this is the relevant code from NamespaceManager:

private static String modName = "AnimalsDropBones";
public static String GetModNameLC(){
	return new String(modName.toLowerCase());
}
public static String getUnLocalized(String key)
    {
    	return NamespaceManager.GetModNameLC() + "_" + key;
    }

 

So. That's NOT the unlocalized name - and it's mixed-case. Let me go adjust those two things - I still need to prefix the modID and a colon onto the unlocalized name, right?

Posted

The unlocalized name is the "glue" that helps associate everything -- blocks pick up their blockstate JSON based on this, and items pick up their model JSON based on that.

 

Unlocalized names can be a bit funny depending on where you are using it. For .lang file purposes it will have "item." in front and ".name" at end. And if you're referencing something by unlocalized name you might need your "modid:" in front of that.

 

However, if you use the getUnlocalizedName() method for the item, it will have the "item." in front of whatever you set. I find this annoying because I believe getter and setter methods should be symmetric. In other words if you set unlocalized to "myitemname" you would get "item.myitemname" back. So I often use substring(5) to strip that off the front.

 

Anyway, best way to debug unlocalized name issues is to simply print out the string to the console before you try to use it. You'll get a sense of when it is a fully qualified name, just the simple name, or something in between.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

This is driving me completely crazy.

 

I changed everything to use lowercase - modID, block names, item names. Since I'm not camel casing, I put underscores in the camel-cased block names. I cleaned out my old resource folder, regenerated all my JSONs reflecting the new naming scheme, and regenerated all my textures (yay scripting).

 

Now NOTHING renders, not even my blocks. I'm getting texture-not-found exceptions for the blocks, and for my METADATA item, but not my SIMPLE items. But they're all pink-and-black cubes.  :'(

 

Now, getting texture-not-found exceptions for the blocks suggests my blocks are loading their JSONs correctly, thus getting told what texture to load - but I have NO CLUE why they'd not FIND the texture, cuz it's right there. *points in frustration at my screen, which you can't see* This was working on Friday. :P

 

So, here's the thing I'm registering my blocks with the mesher with; I've got them all in a LinkedList<>.

 

		ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
	for (int i = 0; i < BlockManager.COMPRESSEDBLOCKS.size(); i++)
	{
		String name = AnimalsDropBones.MODID + ":" + ((BlockCompressed) BlockManager.COMPRESSEDBLOCKS.get(i)).getName();
		AnimalsDropBones.LOG.warn("SYNDARYL: meshing block "  + name );
		mesher.register(
				Item.getItemFromBlock(BlockManager.COMPRESSEDBLOCKS.get(i)), 0, new ModelResourceLocation(
						name, "inventory"
						)
				);
	}

 

 

And then I get the following in the log:

 

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_gravel_compressed

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_cobblestone_compressed

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_stone_compressed

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_dirt_compressed

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_sand_compressed

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_charcoal_compressed

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_bone_compressed

[10:31:52] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones_sugarcane_compressed

 

 

... which is weird, because my MODID isn't in there and I can clearly see me cating it on to that variable I'm printing out.

 

I'm not getting build errors. aaarg.

Posted

So, I've apparently been sent to developer purgatory for my coding sins or something. I rebuilt yet again and this time my debug messages are as expected and my blocks have their textures again. I have no idea what happened, which annoys me because if I did, I could probably figure out why my items are broken. AND all my exceptions have gone away again, which just worries me - should it throw an exception for "can't find JSON" or "no rendering info at all"?

 

Regardless, I'm back to where I started: blocks are fine, items are pink-and-black cubes.

Sledgehammer JSON is sitting in "assets\animalsdropbones\models\item\animalsdropbones_stone_sledgehammer.json" (excuse windows path separators) and contains the following:

 

{
"parent": "builtin/generated",
"textures": {
	"layer0": "animalsdropbones:items/animalsdropbones_stone_sledgehammer"
},
"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]
	}
}
}

 

The image is in  "assets\animalsdropbones\textures\items\animalsdropbones_stone_sledgehammer.png"

I used this image in 1.7.10 without modification and I haven't heard anything about 1.8 changing how it reads PNG files, so it "should" be a valid, working PNG file. I'd expect an exception in my log if Minecraft couldn't read it, anyways...

 

UnLocalizedName set with:

setUnlocalizedName( getName() );

so getName returns getUnlocalizedName() without the item. at the beginning, saving me from calling substr(5) if I don't need it. That sort of magic number thing just looks like I'll shoot myself in the foot with it later.

 

Sledgehammer registered with:

		ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
	String name = AnimalsDropBones.MODID + ":" + sledgehammerStone.getName();
	AnimalsDropBones.LOG.warn("SYNDARYL: item " + name);
	mesher.register(sledgehammerStone, 0, new ModelResourceLocation(name));

 

Debug output:

[10:54:37] [Client thread/WARN]: SYNDARYL: item animalsdropbones:animalsdropbones_stone_sledgehammer

 

Which is exactly like my (working) block output -

[10:54:37] [Client thread/WARN]: SYNDARYL: meshing block animalsdropbones:animalsdropbones_gravel_compressed

 

I've come to the conclusion there's some sort of stupid typo that I can't see somewhere. Any suggestions?

Posted

You didn't put inventory as an argument for the modelresourcelocation. Not sure if it auto-does it but here's what I have:

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(infectedEgg, 0, new ModelResourceLocation("zombieinfection:infectedEgg", "inventory"));

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.