Jump to content

Recommended Posts

Posted

I'm trying to figure out the syntax of a blockstates file. For each variant, I need to define several textures which are always the same, and also define several possible models which will be chosen from randomly. The texture definitions don't need to be different for different models (they have the same texture labels). But the only way I've seen of choosing randomly between models/textures is to make the entire variant definition an array, which would mean having to copy the textures definitions for each model. Is there any way to get around doing that? A way to define the textures once for the variant, and also give an array of possible models to choose from for that variant?

Posted

I think the only option is an array of variants, you can't just have an array of models.

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.

Posted

Thanks anyway. I just tried to use the verbose approach, but it's giving me a "Not a JSON object" error. :S Here is the full blockstates file:

Spoiler

{
    "forge_marker": 1,
    "defaults": {
        "model": "geomastery:trees/tree_small",
        "textures": {
            "bark": "geomastery:blocks/trees/barksize1oak",
            "endgrain": "geomastery:blocks/trees/endgrainoak",
            "all": "geomastery:blocks/trees/leavesoak"
        }
    },
    "variants": {
        "type": {
            "oak": {},
            "birch": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize1birch",
                    "endgrain": "geomastery:blocks/trees/endgrainbirch",
                    "all": "geomastery:blocks/trees/leavesbirch"
                }
            },
            "larch": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize1larch",
                    "endgrain": "geomastery:blocks/trees/endgrainlarch",
                    "all": "geomastery:blocks/trees/leaveslarch"
                }
            },
            "pine": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize1pine",
                    "endgrain": "geomastery:blocks/trees/endgrainpine",
                    "all": "geomastery:blocks/trees/leavespine"
                }
            },
            "spruce": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize1spruce",
                    "endgrain": "geomastery:blocks/trees/endgrainspruce",
                    "all": "geomastery:blocks/trees/leavesspruce"
                }
            },
            "willow": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize1willow",
                    "endgrain": "geomastery:blocks/trees/endgrainwillow",
                    "all": "geomastery:blocks/trees/leaveswillow"
                }
            },
            "beech": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize1beech",
                    "endgrain": "geomastery:blocks/trees/endgrainbeech",
                    "all": "geomastery:blocks/trees/leavesbeech"
                }
            },
            "brazil": [
                {
                    "model": "geomastery:trees/tree_small",
                    "textures": {
                        "bark": "geomastery:blocks/trees/barksize1brazil",
                        "endgrain": "geomastery:blocks/trees/endgrainbrazil",
                        "all": "geomastery:blocks/trees/leavesbrazil"
                    }
                },
                {
                    "model": "geomastery:trees/tree_small_brazil_alt",
                    "textures": {
                        "bark": "geomastery:blocks/trees/barksize1brazil",
                        "endgrain": "geomastery:blocks/trees/endgrainbrazil",
                        "all": "geomastery:blocks/trees/leavesbrazil"
                    }
                }
            ],
            "mahogany": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize1mahogany",
                    "endgrain": "geomastery:blocks/trees/endgrainmahogany",
                    "all": "geomastery:blocks/trees/leavesmahogany"
                }
            },
            "ebony": {
                "textures": {
                    "bark": "geomastery:blocks/trees/barksize12ebony",
                    "endgrain": "geomastery:blocks/trees/endgrainebony",
                    "all": "geomastery:blocks/trees/leavesebony"
                }
            }
        },
        "leaves": {
            "true": { "submodel": { "leaves": { "model": "cube_all" } } },
            "false": {}
        },
        "inventory": [{}]
    }
}

 

The variant I'm trying to define as an array is this:

"brazil": [
  {
    "model": "geomastery:trees/tree_small",
    "textures": {
      "bark": "geomastery:blocks/trees/barksize1brazil",
      "endgrain": "geomastery:blocks/trees/endgrainbrazil",
      "all": "geomastery:blocks/trees/leavesbrazil"
    }
  },
  {
    "model": "geomastery:trees/tree_small_brazil_alt",
    "textures": {
      "bark": "geomastery:blocks/trees/barksize1brazil",
      "endgrain": "geomastery:blocks/trees/endgrainbrazil",
      "all": "geomastery:blocks/trees/leavesbrazil"
    }
  }
],

 

The whole error from the console:

Spoiler

java.lang.Exception: Could not load model definition for variant geomastery:block_tree_small
	at net.minecraftforge.client.model.ModelLoader.getModelBlockDefinition(ModelLoader.java:297) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:121) ~[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.8.0_121]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
	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.8.0_121]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.RuntimeException: Encountered an exception when loading model definition of 'geomastery:block_tree_small' from: 'geomastery:blockstates/block_tree_small.json' in resourcepack: 'FMLFileResourcePack:Geomastery'
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModelBlockDefinition(ModelBakery.java:246) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadMultipartMBD(ModelBakery.java:223) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:208) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.getModelBlockDefinition(ModelLoader.java:293) ~[ModelLoader.class:?]
	... 20 more
Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Not a JSON Object: [{"model":"geomastery:trees/tree_small","textures":{"bark":"geomastery:blocks/trees/barksize1brazil","endgrain":"geomastery:blocks/trees/endgrainbrazil","all":"geomastery:blocks/trees/leavesbrazil"}},{"model":"geomastery:trees/tree_small_brazil_alt","textures":{"bark":"geomastery:blocks/trees/barksize1brazil","endgrain":"geomastery:blocks/trees/endgrainbrazil","all":"geomastery:blocks/trees/leavesbrazil"}}]
	at com.google.gson.Gson.fromJson(Gson.java:815) ~[Gson.class:?]
	at com.google.gson.Gson.fromJson(Gson.java:868) ~[Gson.class:?]
	at com.google.gson.Gson$1.deserialize(Gson.java:126) ~[Gson$1.class:?]
	at net.minecraftforge.client.model.ForgeBlockStateV1$Deserializer.deserialize(ForgeBlockStateV1.java:110) ~[ForgeBlockStateV1$Deserializer.class:?]
	at net.minecraftforge.client.model.ForgeBlockStateV1$Deserializer.deserialize(ForgeBlockStateV1.java:67) ~[ForgeBlockStateV1$Deserializer.class:?]
	at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[TreeTypeAdapter.class:?]
	at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
	at com.google.gson.Gson.fromJson(Gson.java:741) ~[Gson.class:?]
	at net.minecraftforge.client.model.BlockStateLoader.load(BlockStateLoader.java:81) ~[BlockStateLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.parseFromReader(ModelBlockDefinition.java:37) ~[ModelBlockDefinition.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModelBlockDefinition(ModelBakery.java:242) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadMultipartMBD(ModelBakery.java:223) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:208) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.getModelBlockDefinition(ModelLoader.java:293) ~[ModelLoader.class:?]
	... 20 more
Caused by: java.lang.IllegalStateException: Not a JSON Object: [{"model":"geomastery:trees/tree_small","textures":{"bark":"geomastery:blocks/trees/barksize1brazil","endgrain":"geomastery:blocks/trees/endgrainbrazil","all":"geomastery:blocks/trees/leavesbrazil"}},{"model":"geomastery:trees/tree_small_brazil_alt","textures":{"bark":"geomastery:blocks/trees/barksize1brazil","endgrain":"geomastery:blocks/trees/endgrainbrazil","all":"geomastery:blocks/trees/leavesbrazil"}}]
	at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:90) ~[JsonElement.class:?]
	at net.minecraftforge.client.model.ForgeBlockStateV1$Variant$Deserializer.deserialize(ForgeBlockStateV1.java:480) ~[ForgeBlockStateV1$Variant$Deserializer.class:?]
	at net.minecraftforge.client.model.ForgeBlockStateV1$Variant$Deserializer.deserialize(ForgeBlockStateV1.java:440) ~[ForgeBlockStateV1$Variant$Deserializer.class:?]
	at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[TreeTypeAdapter.class:?]
	at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
	at com.google.gson.Gson.fromJson(Gson.java:868) ~[Gson.class:?]
	at com.google.gson.Gson$1.deserialize(Gson.java:126) ~[Gson$1.class:?]
	at net.minecraftforge.client.model.ForgeBlockStateV1$Deserializer.deserialize(ForgeBlockStateV1.java:110) ~[ForgeBlockStateV1$Deserializer.class:?]
	at net.minecraftforge.client.model.ForgeBlockStateV1$Deserializer.deserialize(ForgeBlockStateV1.java:67) ~[ForgeBlockStateV1$Deserializer.class:?]
	at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58) ~[TreeTypeAdapter.class:?]
	at com.google.gson.Gson.fromJson(Gson.java:803) ~[Gson.class:?]
	at com.google.gson.Gson.fromJson(Gson.java:741) ~[Gson.class:?]
	at net.minecraftforge.client.model.BlockStateLoader.load(BlockStateLoader.java:81) ~[BlockStateLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.parseFromReader(ModelBlockDefinition.java:37) ~[ModelBlockDefinition.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModelBlockDefinition(ModelBakery.java:242) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadMultipartMBD(ModelBakery.java:223) ~[ModelBakery.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:208) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.getModelBlockDefinition(ModelLoader.java:293) ~[ModelLoader.class:?]
	... 20 more

 

What am I doing wrong?

Posted

You can only use an array as a fully-defined variant, you can't use it as one of the values of a property.

 

It might be best to register an IStateMapper that uses a different blockstates file for each value of the type property, this way you can define the textures in the defaults section of each file and avoid repeating them for the variants with multiple possible models.

  • Like 1

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.

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.