Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Add direction to the state of a block #116

Open
dymk opened this issue Jan 9, 2014 · 7 comments
Open

Suggestion: Add direction to the state of a block #116

dymk opened this issue Jan 9, 2014 · 7 comments

Comments

@dymk
Copy link
Contributor

dymk commented Jan 9, 2014

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)
@fogleman
Copy link
Owner

fogleman commented Jan 9, 2014

I don't understand the difference between rotation and direction - can you explain?

@Bergasms
Copy link

Bergasms commented Jan 9, 2014

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

@dymk
Copy link
Contributor Author

dymk commented Jan 9, 2014

Sure. Picture a stair, and picture that its "bottom" is placed flat on the ground, like in this orientation: stair

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

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.

@fogleman
Copy link
Owner

fogleman commented Jan 9, 2014

And then you have custom geometry for these special blocks?

@bmathews
Copy link
Contributor

bmathews commented Jan 9, 2014

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.

@dymk
Copy link
Contributor Author

dymk commented Jan 9, 2014

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

@satoshinm
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants