MyNameIsJan Posted August 28, 2021 Posted August 28, 2021 (edited) Hello, when I try to render an item for a block it complains that it can't find the texture. The block is rendered fine and working but the item seems to be unable to find the texture. If the texture is NOT in a subfolder it's working for the item too. Here some screenshot I think are helpful to get a clear view of what I have. Here is where the item of the block get its texture: Here is the folder structure of the textures. As I mentioned before, when I put "block/generator_front" into the "new ResourceLocation()" and put the png file directly under "/block" and not "block/generator" it works. This is where the block is rendered and is getting its texture: And of course the error that is been thrown: Thanks for any help. Edited August 28, 2021 by MyNameIsJan Quote
Gianka1485 Posted August 28, 2021 Posted August 28, 2021 (edited) I think you should do it the old way, you should register the item in the items initializer, example: public class GWorldItems { public static final DeferredRegister<Item> ITEMS; public static final RegistryObject<Item> EXAMPLE_DUST; public static final RegistryObject<Item> EXAMPLE_GEM; public static final RegistryObject<Item> EXAMPLE_BLOCK; static { ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "examplemod"); EXAMPLE_DUST = ITEMS.register("example_dust", () -> { return new Item((new Properties()).tab(ExampleMod.examplemod)); }); EXAMPLE_GEM = ITEMS.register("example_gem", () -> { return new Item((new Properties()).tab(ExampleMod.examplemod)); }); EXAMPLE_BLOCK = ITEMS.register("example_ore", () -> { return new BlockItem((Block) ExampleBlocks.EXAMPLE_ORE.get(), (new Properties()).tab(ExampleMod.examplemod)); }); } } This is how it has always worked and will always work. Edited August 28, 2021 by Gianka1485 Quote
MyNameIsJan Posted August 28, 2021 Author Posted August 28, 2021 Thanks for the reply. The Registration and all that stuff is working and I'm doing it like you said. I split it up into multiple classes and not all in one. I can see my items/blocks ingame. But the item got this purple/black texture. Quote
Gianka1485 Posted August 28, 2021 Posted August 28, 2021 (edited) I was in the bathroom so I couldn't respond quickly, hahaha... I think the problem may come from the .json files of assets /% modid% / models / item Edited August 28, 2021 by Gianka1485 Quote
Choonster Posted August 28, 2021 Posted August 28, 2021 The second argument of withExistingParent is the path to a model file to use as a parent, not a texture. For basic block items, the model normally uses the block model as the parent, rather than specifying individual textures. I use this helper method in my BlockStateProvider implementation to generate block item models that simply extend the block model. You can see an example of this here. On a side note, the DeferredRegister instance should always be created in the same class as it's used in; don't put the DeferredRegister and RegistryObject fields in separate classes. 1 Quote 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.
Gianka1485 Posted August 28, 2021 Posted August 28, 2021 When you want a block to have a texture, it must have the following information (although it may vary): { "parent": "examplemod:block/example_block" } Quote
Gianka1485 Posted August 28, 2021 Posted August 28, 2021 2 minutes ago, Choonster said: The second argument of withExistingParent is the path to a model file to use as a parent, not a texture. For basic block items, the model normally uses the block model as the parent, rather than specifying individual textures. I use this helper method in my BlockStateProvider implementation to generate block item models that simply extend the block model. You can see an example of this here. On a side note, the DeferredRegister instance should always be created in the same class as it's used in; don't put the DeferredRegister and RegistryObject fields in separate classes. Better explained impossible. Quote
MyNameIsJan Posted August 28, 2021 Author Posted August 28, 2021 (edited) 26 minutes ago, Choonster said: The second argument of withExistingParent is the path to a model file to use as a parent, not a texture. For basic block items, the model normally uses the block model as the parent, rather than specifying individual textures. I use this helper method in my BlockStateProvider implementation to generate block item models that simply extend the block model. You can see an example of this here. On a side note, the DeferredRegister instance should always be created in the same class as it's used in; don't put the DeferredRegister and RegistryObject fields in separate classes. Thanks a lot. And also for the little side note Just one question... why do they have to be in one class? I know that the block needs to be registered before the item so as long as I take care of that it should be fine, right? Or is this some best practice? If you got any further advice I'll take them Have a nice rest of the day Edited August 28, 2021 by MyNameIsJan Quote
Recommended Posts
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.