Jump to content

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


Adil Yilan

Recommended Posts

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 :)

 

 

 

 

Link to comment
Share on other sites

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.