Jump to content

[Solved] [1.10.2] Forge Blockstate: Texture choice depends on multiple values


Recommended Posts

Posted (edited)

I have a block that has two boolean values (top or bottom block & with or without glass), an enum like value that is built in the state mapper from two booleans (right, center or left block) and an orientation. For the normal version of the block without glass I am using the standard blockstate format. But to create the block with glass, I need to use the Forge Blockstate format to have different model parts render in different BlockRenderLayers. My problem is that the texture of the block is determined by the top or bottom boolean value and by the enum value (right / left / center). Is there a way to do this in the Forge Blockstate format?

 

This is what I tried:

{
	"forge_marker": 1,
	"defaults": {
		"model": "forge:multi-layer",
		"transform": "forge:default-block",
		"custom": {
			"base": "rssmc:blockBarricadeWindowLarge#down",
			"Solid": "rssmc:blockBarricadeWindowLarge#down",
			"Cutout": "rssmc:blockBarricadeWindowLarge#window"
		}
	},
	"variants": {
		"normal": [{}],
		"inventory": [{}],
		"down": [{
			"model": "rssmc:block_barricade_bottom_window",
			"side": {
				"right": {
					"textures": {
						"0": "rssmc:blocks/block_barricade_bottom_right"
					}
				},
				"left": {
					"textures": {
						"0": "rssmc:blocks/block_barricade_bottom_left"
					}
				},
				"center": {
					"textures": {
						"0": "rssmc:blocks/block_barricade_bottom_center"
					}
				}
			}
		}],
		"up": [{
			"model": "rssmc:block_barricade_top_window",
			"side": {
				"right": {
					"textures": {
						"0": "rssmc:blocks/block_barricade_top_right"
					}
				},
				"left": {
					"textures": {
						"0": "rssmc:blocks/block_barricade_top_left"
					}
				},
				"center": {
					"textures": {
						"0": "rssmc:blocks/block_barricade_top_center"
					}
				}
			}
		}],
		"window": [{
			"model": "rssmc:block_glass_pane"
		}],
		"top": {
			"true": {
				"custom": {
					"Solid": "rssmc:blockBarricadeWindowLarge#up"
				}
			},
			"false": { }
		},
		"facing": {
			"north": { },
			"south": {"y": 180},
			"west": {"y": 270},
			"east": {"y": 90}
		}
	}
}

The "side" block is what creates the problem.

Edited by XFactHD
Fixed an error in the code
Posted

Using the value in the json file is not the problem. The problem is that I need to use multiple values at once to determine a texture and that seems to not be possible.

Posted

I got it to work now by special casing the crap out of the state mapper which is comething I would have loved to avoid.

Posted

You would need a custom IStateMapper.

For example, I needed something like this, so I used two blockstate files and used the mapper to decide which one to load. 

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/flowers/states/StateMapperFlowers.java

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.

Posted

I am already using a custom IStateMapper and because of the obscene amount of states the block has, I am already dividing it into four blockstate files.

Posted

Yes, but you can do other things as well. You just need to figure out how to map the states.

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.

Posted

In the end I had to make one enum like value out of three booleans in the statemapper. I would have preferred to be able to do nested conditions but that seems to not be possible.

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.