Craft
Craft copied to clipboard
Suggestion: Add direction to the state of a block
What possibilities does this open up? Well, meta-blocks like torches, ladders (where the attach point would otherwise be ambiguous, such as at the corner of two blocks), and the big one I'd like to try and implement at some point: stairs.
@fogleman, thoughts on this? I could work on it, but I'd like to know if it has a good chance of making it into the mainline before putting in a lot of effort. Note that it'd just be for adding a direction (orientation/direction as a single attribute) to blocks (which would be ignored for the blocks in the current game), not adding stairs (which I'd like to do after this, if it gets green-lighted).
The idea is to add another attribute to the blocks, in the form of a short
(or two unsigned char
?).
0000 0000
\--/ \--/
| \-> low byte: rotation (up, down, left, right)
v
high byte: direction (north, south, east, west, up, down)
I don't understand the difference between rotation and direction - can you explain?
@fogleman I think he means one if for rotation around y, and one is for placement in y. So for example you can have stairs that are facing north (the stairs have the pointy end facing north) but they can be upside down or the right side up. At least that is how i understand it. and you could use less bits for that.
Sure. Picture a stair, and picture that its "bottom" is placed flat on the ground, like in this orientation:
So that'd be a stair facing the up direction. Now, if you were to have placed that while looking upwards in minecraft, placing it on the ceiling of something, you'd have a stair like this:
And then rotation is rotation around the axis that runs through the top and bottom of a block.
Now that I think about it, I don't know if stairs in vanilla minecraft can have a direction other than up and down, but they can have all four rotations. Either way, it still needs a distinction between direction and rotation to get all 8 placement combinations. I'll try it out and see if you can place stairs on their "backs".
Edit: Yep, tested it out, stairs can have 4 rotations, but only two directions: rightside up and upside down. So that simplifies directions quite a bit. One could technically get away with storing both direction/rotation in 3 bits, but I'm not sure what that'd do for performance with all that masking and shifting.
And then you have custom geometry for these special blocks?
Custom geometry could fall in with the idea I posted of a plugin architecture, but it wouldn't be a walk in the park. Would be cool to add someone's 'stair' plugin to your client and server.
yep, custom geometry, drawn in a similar manner as how flowers are drawn (e.g., just add another check when drawing blocks around lines 871 in main.c
- is the item a stair?).
Rather than adding another attribute to blocks, another option could be to use multiple block IDs, one for each orientation/rotation of the same block (imho this would be cleaner/simpler/smaller than segmenting the block space).