Jump to content

Recommended Posts

Posted (edited)

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 by IMleader
Posted
[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

Posted

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.

Posted

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.

Posted (edited)

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 by Jay Avery
Posted

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.

Posted

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

Posted

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.

Posted
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?

Posted

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.

Posted

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?

Posted (edited)

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 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.

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.