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.

[1.18.2] Using same model for different values of same block state property

Featured Replies

Posted

I have a crop that has AGE property that changes from 0 to 29.

There are 5 different block models:

  • Stage 0 - AGE from 0 to 5
  • Stage 1 - AGE from 6 to 11
  • Stage 2 - AGE from 12 to 17
  • Stage 3 - AGE from 18 to 23
  • Stage 4 - AGE from 24 to 29

For every stage there is a different model.

My blockstate JSON file looks like this:

{
	"variants":{
		"age=0" : {
			"model" : "experimentalmod:block/fruit_plant_stage_0"
		},
		"age=1" : {
			"model" : "experimentalmod:block/fruit_plant_stage_0"
		},
		"age=2" : {
			"model" : "experimentalmod:block/fruit_plant_stage_0"
		},
		"age=3" : {
			"model" : "experimentalmod:block/fruit_plant_stage_0"
		},
		"age=4" : {
			"model" : "experimentalmod:block/fruit_plant_stage_0"
		},
		"age=5" : {
			"model" : "experimentalmod:block/fruit_plant_stage_0"
		},
		"age=6" : {
			"model" : "experimentalmod:block/fruit_plant_stage_1"
		},
		"age=7" : {
			"model" : "experimentalmod:block/fruit_plant_stage_1"
		},
		"age=8" : {
			"model" : "experimentalmod:block/fruit_plant_stage_1"
		},
		"age=9" : {
			"model" : "experimentalmod:block/fruit_plant_stage_1"
		},
		"age=10" : {
			"model" : "experimentalmod:block/fruit_plant_stage_1"
		},
		"age=11" : {
			"model" : "experimentalmod:block/fruit_plant_stage_1"
		},
		...
	}
}

Although this works, I find it terrible from the code quality perspective.

I have searched for any clues on how to use same model for different variants but without success.

Is there a way to say:

  • For AGE values from 0 to 5 use model fruit_plant_stage_0
  • For AGE values from 6 to 11 use model fruit_plant_stage_1
  • ...etc

Thanks :)

 

 

 

 

  • Author

@diesieben07 Adding data generator for this is def something I had in plan, but I am not sure if this is most optimized JSON output, regardless if it is manual or auto generated.

Can it be improved / regrouped in a way I have envisioned to have multiple variants point to same model?

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.