Posted June 9, 20178 yr Hello! I am working on a block that has multiple states and based on the state, it has a different color. I have made the block and it registers all of the variants, but how exactly does the .json work. I know how it works for a regular block. But I cannot get it to work for the JSON part. I tried to look at Minecraft assets to no avail. Source can be found here: https://github.com/xXXIMMATTHEWXXx/MyCraft How do I setup the JSON for different block states to use a different texture? Some explanation. I use all of the default Minecraft colors and create a sub-block of the block. This leads to 16 different blocks Edited June 9, 20178 yr by IMleader
June 9, 20178 yr The forge docs have an overview of the vanilla blockstates format (fine for simple blocks like yours), and the forge blockstates format (more versatile but marginally more complicated).
June 9, 20178 yr Author Ive tried it with the orange and white models but it still throws an model error https://github.com/xXXIMMATTHEWXXx/MyCraft/blob/master/src/main/resources/assets/mycraft/blockstates/sim_light_color.json Edited June 9, 20178 yr by IMleader Link
June 9, 20178 yr Author [14:41:57] [Client thread/ERROR] [FML]: Exception loading model for variant mycraft:sim_light_block_color#color=white for blockstate "mycraft:sim_light_block_color[color=white]" net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model mycraft:sim_light_block_color#color=white with loader VariantLoader.INSTANCE, skipping at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?] at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:264) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:252) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:159) ~[ModelLoader.class:?] at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [SimpleReloadableResourceManager.class:?] at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_79] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_79] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_79] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_79] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] For each color
June 9, 20178 yr That means that you don't have a variant for that colour. Take a look at the docs I linked you, and make sure your blockstates file contains a variant for every colour in the correct format.
June 9, 20178 yr Author The problem is white is still showing an error even though the white one is in there.
June 9, 20178 yr A blockstates file won't be processed correctly unless it has all the possible states in it - so even if the one variant is correct, it won't render if another variant is wrong or missing.
June 9, 20178 yr Check the forge blockstates format rules again. The variants for a property like colour should not be in an array (in square brackets). Edit: You also have a json syntax error, an extra comma at the end of the "black" variant. Use an online json validator or a plugin for your IDE to catch syntax mistakes like this. Edited June 9, 20178 yr by Jay Avery
June 9, 20178 yr For a version with only two colours, you will need to change the way your block's properties are coded. Are you still getting model errors in the console? If so, post them.
June 9, 20178 yr Author I wanted to version with two colors only so i can see how it works. Dont want you to do more work so if you could show me the correct way with two colors ill do the rest
June 9, 20178 yr I'm not going to write it for you. You're very close to getting it right, and talking you through the errors with your version will teach you far more than just giving you a working replacement.
June 9, 20178 yr Author Haah! You were right, the [] made an array. Weird how that works but it goes to the textures now. All good
June 9, 20178 yr Author 22 minutes ago, Jay Avery said: I'm not going to write it for you. You're very close to getting it right, and talking you through the errors with your version will teach you far more than just giving you a working replacement. I have a new issue. I set the creative tab to decor. But it does not show up and i cannot give myself the block?
June 9, 20178 yr You never create an ItemBlock for your SimLightBlock. An ItemBlock is the thing which exists in the inventory and creative tabs, a Block is the thing which exists physically in the world.
June 9, 20178 yr Author I have made this but it says that a registery name is not set for the item. But my other register name for the block is based off of the meta data. How do i go about this?
June 9, 20178 yr Why is the registry name based on the blockstate? I'm pretty sure there should always be exactly one registry name per block, not per block variant.
June 10, 20178 yr When you create the ItemBlock for the variable block, you need to use (or imitate) the ItemMultiTexture class that sets hasSubtypes to true. It'll need a method to generate a name suffix for each "damage" (metadata) value so your client proxy can create a resource location for each item subtype: if (i.getHasSubtypes ()) { ResourceLocation[] variant = new ResourceLocation[varSuffixes.length]; // Not to be confused with *model* locations for (int meta = 0; meta < varSuffixes.length; meta++ ) { variant[meta] = new ResourceLocation (i.getRegistryName ().toString () + '_' + varSuffixes[meta]); ModelResourceLocation m = new ModelResourceLocation (variant[meta], "inventory"); ModelLoader.setCustomModelResourceLocation (i, meta, m); } ModelBakery.registerItemVariants (i, variant); } In this code snippet, 'i' is my item, and varSuffixes is an array of strings that I passed into this client proxy method. Edited June 10, 20178 yr by jeffryfisher The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
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.