riky181 Posted August 29, 2016 Posted August 29, 2016 Hello, i've created a block in my ModBlocks class. When i place it the texture works perfectly fine but it won't render in my inventory. (Jason and texture images are all named correctly). Here is my code: public class ModBlocks { public static Block black_cobblestone; public static void init() { black_cobblestone = new Block(Material.ROCK).setRegistryName("black_cobblestone").setUnlocalizedName("black_cobblestone").setCreativeTab(Tabs.tabStoneBlocks); } public static void registerRenders() { registerRender(black_cobblestone); } public static void register() { registerBlock(black_cobblestone); } public static void registerBlock(Block block) { GameRegistry.register(block); ItemBlock item = new ItemBlock(block); item.setRegistryName(block.getRegistryName()); GameRegistry.register(item); } public static void registerRender(Block block) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } } I don't have any separate class for each item. Please can you help it is really important thanks! Quote
Matryoshika Posted August 29, 2016 Posted August 29, 2016 [*]Do not use Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register for rendering. It's purely the years of experience and extensive knowledge of the rendering system, that let the Mojang coders keep the vanilla rendering "above the water". [*]Use the forge provided ModelLoader instead: Exactly the same variables used to call it. Just switch out Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register for ModelLoader.setCustomModelResourceLocation [*] ModelLoader rendering has to be called in preInit , of course, after the blocks & items have been registered. Quote 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.
riky181 Posted August 29, 2016 Author Posted August 29, 2016 I've done what you said, now the registeRenders is like this: ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "Inventory")); But now the game crashes, here is the crash report ---- Minecraft Crash Report ---- // Ouch. That hurt Time: 8/29/16 11:37 AM Description: Initializing game java.lang.NullPointerException: Initializing game at net.minecraftforge.client.model.ModelLoader.setCustomModelResourceLocation(ModelLoader.java:1095) at com.rage.mod.init.ModBlocks.registerRender(ModBlocks.java:49) at com.rage.mod.init.ModBlocks.registerRenders(ModBlocks.java:30) at com.rage.mod.proxy.ClientProxy.preInit(ClientProxy.java:17) at com.rage.mod.main.Main.preInit(Main.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:597) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:239) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:217) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:142) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:607) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:255) at net.minecraft.client.Minecraft.startGame(Minecraft.java:477) at net.minecraft.client.Minecraft.run(Minecraft.java:386) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at net.minecraftforge.client.model.ModelLoader.setCustomModelResourceLocation(ModelLoader.java:1095) at com.rage.mod.init.ModBlocks.registerRender(ModBlocks.java:49) at com.rage.mod.init.ModBlocks.registerRenders(ModBlocks.java:30) at com.rage.mod.proxy.ClientProxy.preInit(ClientProxy.java:17) at com.rage.mod.main.Main.preInit(Main.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:597) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:239) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:217) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:142) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:607) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:255) at net.minecraft.client.Minecraft.startGame(Minecraft.java:477) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:386) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.10.2 Operating System: Mac OS X (x86_64) version 10.11.3 Java Version: 1.8.0_65, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 810039560 bytes (772 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.32 Powered by Forge 12.18.1.2073 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCH mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.1.2073.jar) UCH Forge{12.18.1.2073} [Minecraft Forge] (forgeSrc-1.10.2-12.18.1.2073.jar) UCE bcraft{1.10-R1} [block Craft] (bin) Loaded coremods (and transformers): Launched Version: 1.10.2 LWJGL: 2.9.2 OpenGL: NVIDIA GeForce GT 750M OpenGL Engine GL version 2.1 NVIDIA-10.8.14 310.42.15f01, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because ARB_framebuffer_object is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 8x Intel® Core i7-4980HQ CPU @ 2.80GHz Quote
Matryoshika Posted August 29, 2016 Posted August 29, 2016 Think I already know why, but please post your proxies & main file, preferably inside: one of these Quote 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.
riky181 Posted August 29, 2016 Author Posted August 29, 2016 Main class: package com.rage.mod.main; import org.apache.logging.log4j.Logger; import com.rage.mod.proxy.CommonProxy; import net.minecraft.block.Block; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION) public class Main { @SidedProxy(clientSide = Reference.CLIENTPROXY, serverSide = Reference.COMMONPROXY) public static CommonProxy proxy; @Instance public static Main instance; public static Logger logger; @EventHandler public void preInit(FMLPreInitializationEvent event) { logger = event.getModLog(); proxy.preInit(event); } @EventHandler public void init(FMLInitializationEvent event) { proxy.init(event); } @EventHandler public void postInit(FMLPostInitializationEvent event) { proxy.postInit(event); } } Client Proxy package com.rage.mod.proxy; import com.rage.mod.init.ModBlocks; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent event) { super.preInit(event); ModBlocks.init(); ModBlocks.registerRenders(); ModBlocks.register(); } @Override public void init(FMLInitializationEvent event) { super.init(event); } @Override public void postInit(FMLPostInitializationEvent event) { super.postInit(event); } } Common Proxy package com.rage.mod.proxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class CommonProxy { public void preInit(FMLPreInitializationEvent event) { } public void init(FMLInitializationEvent event) { } public void postInit(FMLPostInitializationEvent event) { } } Quote
Matryoshika Posted August 29, 2016 Posted August 29, 2016 yeah, as I thought. ModelLoader rendering has to be called in preInit , of course, after the blocks & items have been registered. You try to set the render for blocks, that does not yet exist. Switch these around: ModBlocks.registerRenders(); ModBlocks.register(); Quote 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.
riky181 Posted August 29, 2016 Author Posted August 29, 2016 Dude thanks works perfectly fine! Ur a lifesaver! Quote
Matryoshika Posted August 29, 2016 Posted August 29, 2016 >_< Damnit, failed to see in time. If you read this post, would you mind answering why you have your Block Registration, in the Client-Proxy? That should be in the common-proxy, otherwise, if you load up a server with this, there will not be any blocks, because the server cannot see them, literally, if the server doesn't crash before that. Quote 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.
Draco18s Posted August 29, 2016 Posted August 29, 2016 If you read this post, would you mind answering why you have your Block Registration, in the Client-Proxy? That should be in the common-proxy Or your main mod class. I see no point in passing off the initialization events to the proxy classes when they can just do the work themselves. Prior to 1.8 my common proxy would be virtually empty except for the stub methods for the client proxy to override. Now in 1.10 it contains several wrapper methods around GameRegistry.register so I don't have to set the registryName between creating the item and registering it. End result, my main class is full of the dirty work (a lot of people put this in a ModBlocks class, and that's fine, but there's litterally no reason to pass the event off to the proxy, only to call ModBlocks.doStuff(): just call doStuff from Main!) Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Matryoshika Posted August 29, 2016 Posted August 29, 2016 True. I use Main quite a bit myself, though the fact still stands: His code should be somewhere that is executed on both Server and Client threads. Quote 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.
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.