Jump to content

How to change block orientation depending on player`s facing during block placement?


Recommended Posts

Hello. I want to add block called "statue" to my mod and it is very important to provide user an opportunity to control block orientation.

It always looks one way. Is there a special property to fix this (I have checked official documentation page several times but didn`t find anything...😅)?

Thanks in advance)

2021-05-04_19-23-41.png

Link to comment
Share on other sites

This may or may not be helpful, but I used stairs.json as a reference. These, in particular, are the important parts:

	class: "BlockStairs",
	variantgroups: [
		{ loadFromProperties: "abstract/verticalorientation" },
		{ loadFromProperties: "abstract/horizontalorientation" },
		{ code: "cover", states: ["free", "snow"] }
	],

I think the class and vertical/horizontal properties are what help control orientation. If you look further down, you'll see this:

	shapebytype: { 
		"*-up-north-free": { base: "block/basic/stairs/normal", rotateY: 0 },
		"*-up-west-free": { base: "block/basic/stairs/normal", rotateY: 90 },
		"*-up-south-free": { base: "block/basic/stairs/normal", rotateY: 180 },
		"*-up-east-free": { base: "block/basic/stairs/normal", rotateY: 270 },
		"*-up-north-snow": { base: "block/basic/stairs/snow-normal", rotateY: 0 },
		"*-up-west-snow": { base: "block/basic/stairs/snow-normal", rotateY: 90 },
		"*-up-south-snow": { base: "block/basic/stairs/snow-normal", rotateY: 180 },
		"*-up-east-snow": { base: "block/basic/stairs/snow-normal", rotateY: 270 },
		"*-down-north-free": { base: "block/basic/stairs/flipped", rotateY: 0 },
		"*-down-west-free": { base: "block/basic/stairs/flipped", rotateY: 90 },
		"*-down-south-free": { base: "block/basic/stairs/flipped", rotateY: 180 },
		"*-down-east-free": { base: "block/basic/stairs/flipped", rotateY: 270 }
	},

Something like this will probably give you the results you want. You probably don't need vertical orientation unless you're planning on letting people place those statues upside down. 😅

EDIT: Also, those are very nice textures. Too nice for this game. I would recommend heavily downscaling the texture and applying a bit of noise to make it fit in better... or you could probably use the existing stone textures in-game. Your call!

Edited by l33tmaan
  • Thanks 1
Link to comment
Share on other sites

Finally, I found the solution. To implement such experience, you should add this code:

behaviors: [ { "name": "HorizontalOrientable" } ],
variantgroups: [
    {
      code: "side",
      loadFromProperties: "abstract/horizontalorientation"
    }
  ],
 creativeinventoryByType: {
   "*-east": {general: ["*"]}
},
 shape: {
   base: "block/yourblockmodel",
    "rotateYByType": {
      "*-north": 0,
      "*-east": 270,
      "*-south": 180,
      "*-west": 90
    }
 },

 

Edited by TheAnubisGod
  • Like 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.