In 1.8.9, the way block models work changed. I've tried to figure it out, but it mostly doesn't make sense, and I'm trying to create a custom torch with the default model. I have a block that acts like a torch, with the placement and rotation and everything (it extends BlockTorch), though the model is just the default black and purple solid cube.
Can someone explain how these new models work, and how I can assign the Minecraft torch model to a custom block that extends BlockTorch?
I suggest MrCrayFish's model creator. Also, (assuming you're using eclipse)if you go to Referenced Libraries>forgeSrc(It should be the top one)>assets>minecraft>models>block, and there should be 2 files named torch_wall.json and torch.json. They might help you with the problem you're having.
I suggest MrCrayFish's model creator. Also, (assuming you're using eclipse)if you go to Referenced Libraries>forgeSrc(It should be the top one)>assets>minecraft>models>block, and there should be 2 files named torch_wall.json and torch.json. They might help you with the problem you're having.
Thanks for the reply, but I'm not trying to use a custom model, just use the minecraft torch one. I've updated my original post to make more sense. I have found the model files, but I have no idea to use them, and my attempts to use them have failed. My question is more along the lines of "how do I give a model to a block" than "how do I make a model".
and then put or create a .json file (in eclipse its a untitled text file and the save the extension as .json) into that folder with the same name as your block. Then into that file put the model for the block
Hope this helps!
How do I make sure that the torch model is correctly rotated depending on what block it's connected to?
OK, well I replaced my blockstate model with the one you provided, here. It still doesn't appear to work, I don't think I understand this whole block model thing well enough. I think I have it registered to use the model, here, but apparently not. Why isn't this working, and how exactly does this whole thing work?
- First, it doesn't work. It says I need an Item instead of Block for the first one, and a ModelResourceLocation for the second. What does it mean by item, does it mean I have to register blocks a different way, or that is it some other definition of item? Also what is a ModelResourceLocation?
- I imagine that ModelLoader.setCustomModelResourceLocation is a simpler way than the other one? Would you mind a small explanation of this method?
- Why should I not use that method? What is the difference between an unlocalized name and a registry name?
Item.getItemFromBlock(ModBlocks.torch_burnt) - Gets the inventory ItemBlock (The "block" shown in the inventory) associated with the block. Blocks themselves only exist in world. The blocks you have in your inventory are actually an Item that place the Block when right clicking on another block in the world.
A ModelResourceLocation is a ResourceLocation (in this case, the path to the blockstate or model file) and a variant name. In your case, you'll probably want to use new ModelResourceLocation(new ResourceLocation(HardcoreTorches.MODID, "burnt_torch"), "inventory").
ModelLoader.setCustomModelResourceLocation(...) is the Forge added method for model registration. It allows for better Forge support and has the same end result.
An Unlocalized Name is literally only used for lang files. It should have 0 effect on backend features. Registry Names are unique ID's that are used to reference your block.
Also, remove your call of ItemRenderRegister.registerItemRenderer() from HardcoreTorches. It is already called from your ClientProxy. You will currently crash on servers due to calling client things on the server. Move the ItemRenderRegister and BlockRenderRegister calls to preInit, as well.
Item.getItemFromBlock(ModBlocks.torch_burnt) - Gets the inventory ItemBlock (The "block" shown in the inventory) associated with the block. Blocks themselves only exist in world. The blocks you have in your inventory are actually an Item that place the Block when right clicking on another block in the world.
A ModelResourceLocation is a ResourceLocation (in this case, the path to the blockstate or model file) and a variant name. In your case, you'll probably want to use new ModelResourceLocation(new ResourceLocation(HardcoreTorches.MODID, "burnt_torch"), "inventory").
ModelLoader.setCustomModelResourceLocation(...) is the Forge added method for model registration. It allows for better Forge support and has the same end result.
An Unlocalized Name is literally only used for lang files. It should have 0 effect on backend features. Registry Names are unique ID's that are used to reference your block.
Also, remove your call of ItemRenderRegister.registerItemRenderer() from HardcoreTorches. It is already called from your ClientProxy. You will currently crash on servers due to calling client things on the server. Move the ItemRenderRegister and BlockRenderRegister calls to preInit, as well.
It worked! At least, for the in-world bloc. Which I don't understand, considering I used Item.getItemFromBlock(ModBlocks.torch_burnt). How does the in-world block get the model if I specified to use the item? Either way it works now, but the inventory item is still a cube. Is method for registering items similar to the block registering?
It worked! At least, for the in-world bloc. Which I don't understand, considering I used Item.getItemFromBlock(ModBlocks.torch_burnt). How does the in-world block get the model if I specified to use the item? Either way it works now, but the inventory item is still a cube. Is method for registering items similar to the block registering?
The Block's model is specified by its blockstates file. ModelLoader.setCustomModelResourceLocation only affects the Item's model.
There should be an error in the log telling you why the model/texture wasn't loaded. If you don't know what to make of it, upload the FML log (logs/fml-client-latest.log) to Gist and link it here.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The Block's model is specified by its blockstates file. ModelLoader.setCustomModelResourceLocation only affects the Item's model.
There should be an error in the log telling you why the model/texture wasn't loaded. If you don't know what to make of it, upload the FML log (logs/fml-client-latest.log) to Gist and link it here.
Now this makes sense, but what happened does not. I've attached a file. The block model works, but the inventory does not, which makes no sense if it only affects the item's model.
Minecraft couldn't find item models at the locations you specified, so it tried to load the model from the blockstates files. Those didn't exist either, so it logged those errors. The error reporting has been improved in 1.9 (in response to this issue), it now shows the item and blockstates exceptions when an item's model couldn't be loaded.
[12:13:46] [Client thread/ERROR] [FML/]: Model definition for location hardcoretorches:hardcoretorches:torch_burnt#inventory not found
You've added an extra prefix to this model location, so there's no way it can point to an actual file.
[12:13:46] [Client thread/ERROR] [FML/]: Model definition for location hardcoretorches:burnt_torch#inventory not found
An exception was thrown while loading this item model, either because it was invalid or didn't exist.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Minecraft couldn't find item models at the locations you specified, so it tried to load the model from the blockstates files. Those didn't exist either, so it logged those errors. The error reporting has been improved in 1.9 (in response to this issue), it now shows the item and blockstates exceptions when an item's model couldn't be loaded.
You've added an extra prefix to this model location, so there's no way it can point to an actual file.
An exception was thrown while loading this item model, either because it was invalid or didn't exist.
Sorry, but now I'm even more confused. I have a block states file, here. In that case I'm assuming I spelled something wrong?
I don't know how I added an extra prefix, my code to register items is in a class:
package com.github.wolfiewaffle.hardcoretorches.client.render.items;
import com.github.wolfiewaffle.hardcoretorches.HardcoreTorches;
import com.github.wolfiewaffle.hardcoretorches.blocks.ModBlocks;
import com.github.wolfiewaffle.hardcoretorches.items.ModItems;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
public class ItemRenderRegister {
public static String modid = HardcoreTorches.MODID;
public static void registerItemRenderer() {
reg(ModItems.animal_fat);
reg(Item.getItemFromBlock(ModBlocks.torch_burnt));
}
public static void reg(Item item) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(HardcoreTorches.MODID, "torch_burnt"), "inventory"));
}
}
And I don't know exactly how it works, for example what the "inventory" is for. I found that the name was "burnt_torch" instead of "torch_burnt," but fixing that didn't help. How does minecraft use and find the models for the inventory and blocks? If I could understand this better I might be able to fix it myself.
UPDATE: I still don't know exactly what I'm doing, but I'm guessing that registry names have he format "modid:item" rather than "item", which is where I got the extra prefix. I'm trying a different method of registry so hopefully that will work.
OK, so I changed some things and now the item models work. However I had to use the
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(ModBlocks.torch_burnt), 0, new ModelResourceLocation("hardcoretorches:torch_burnt", "inventory"));
method for the Item render register. I remember TehNut saying not to use that method, but why? It seems to be the only thing that works for me.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
In 1.8.9, the way block models work changed. I've tried to figure it out, but it mostly doesn't make sense, and I'm trying to create a custom torch with the default model. I have a block that acts like a torch, with the placement and rotation and everything (it extends BlockTorch), though the model is just the default black and purple solid cube.
Can someone explain how these new models work, and how I can assign the Minecraft torch model to a custom block that extends BlockTorch?
I suggest MrCrayFish's model creator. Also, (assuming you're using eclipse)if you go to Referenced Libraries>forgeSrc(It should be the top one)>assets>minecraft>models>block, and there should be 2 files named torch_wall.json and torch.json. They might help you with the problem you're having.
Thanks for the reply, but I'm not trying to use a custom model, just use the minecraft torch one. I've updated my original post to make more sense. I have found the model files, but I have no idea to use them, and my attempts to use them have failed. My question is more along the lines of "how do I give a model to a block" than "how do I make a model".
How do I make sure that the torch model is correctly rotated depending on what block it's connected to?
https://github.com/TehNut/Torcherino/blob/1.8.8/src/main/resources/assets/torcherino/blockstates/tile.torcherino.json
It looks like that repo is removed, do you have a copy?
EDIT: It looks like the regular repo is also 1.8.9, I'll look there
OK, well I replaced my blockstate model with the one you provided, here. It still doesn't appear to work, I don't think I understand this whole block model thing well enough. I think I have it registered to use the model, here, but apparently not. Why isn't this working, and how exactly does this whole thing work?
That torch_burnt file is not a .json file.
To nitpick that class a little bit:
See Choonster's post here.
Thanks, didn't catch the missing file extension
As for the second part, I changed that line to:
However I have a few questions:
- First, it doesn't work. It says I need an Item instead of Block for the first one, and a ModelResourceLocation for the second. What does it mean by item, does it mean I have to register blocks a different way, or that is it some other definition of item? Also what is a ModelResourceLocation?
- I imagine that ModelLoader.setCustomModelResourceLocation is a simpler way than the other one? Would you mind a small explanation of this method?
- Why should I not use that method? What is the difference between an unlocalized name and a registry name?
Also, remove your call of ItemRenderRegister.registerItemRenderer() from HardcoreTorches. It is already called from your ClientProxy. You will currently crash on servers due to calling client things on the server. Move the ItemRenderRegister and BlockRenderRegister calls to preInit, as well.
It worked! At least, for the in-world bloc. Which I don't understand, considering I used Item.getItemFromBlock(ModBlocks.torch_burnt). How does the in-world block get the model if I specified to use the item? Either way it works now, but the inventory item is still a cube. Is method for registering items similar to the block registering?
The Block's model is specified by its blockstates file. ModelLoader.setCustomModelResourceLocation only affects the Item's model.
There should be an error in the log telling you why the model/texture wasn't loaded. If you don't know what to make of it, upload the FML log (logs/fml-client-latest.log) to Gist and link it here.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Now this makes sense, but what happened does not. I've attached a file. The block model works, but the inventory does not, which makes no sense if it only affects the item's model.
I found this in the log file: https://gist.github.com/anonymous/9489be985c36abf06062a6f662b32b76
Minecraft couldn't find item models at the locations you specified, so it tried to load the model from the blockstates files. Those didn't exist either, so it logged those errors. The error reporting has been improved in 1.9 (in response to this issue), it now shows the item and blockstates exceptions when an item's model couldn't be loaded.
You've added an extra prefix to this model location, so there's no way it can point to an actual file.
An exception was thrown while loading this item model, either because it was invalid or didn't exist.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Sorry, but now I'm even more confused. I have a block states file, here. In that case I'm assuming I spelled something wrong?
I don't know how I added an extra prefix, my code to register items is in a class:
And I don't know exactly how it works, for example what the "inventory" is for. I found that the name was "burnt_torch" instead of "torch_burnt," but fixing that didn't help. How does minecraft use and find the models for the inventory and blocks? If I could understand this better I might be able to fix it myself.
UPDATE: I still don't know exactly what I'm doing, but I'm guessing that registry names have he format "modid:item" rather than "item", which is where I got the extra prefix. I'm trying a different method of registry so hopefully that will work.
OK, so I changed some things and now the item models work. However I had to use the
method for the Item render register. I remember TehNut saying not to use that method, but why? It seems to be the only thing that works for me.
However the block model works perfect, thanks!
Did you move your rendering registration methods to preInit like I told you to? Your Git repo says otherwise.
I've written a description of the model loading process here.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
I did that and it crashed: https://gist.github.com/anonymous/bfedcf9d8e0326a26311998295398096
EDIT: wait derp, I think I messed that up