Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

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.

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.

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.

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.

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.

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.