9

Dont blame me for making Minecraft plugins, but holy shit i really hate stairs right now.

Im modifying some old code of mine to add extra features, and i just need to be able to rotate stairs 90, 180 and 270 degrees, then im past this bump.

Stairs get their direction based on a byte value that makes no fucking sense to me.

North = 3
West = 1
East = 0
South = 2

Ive been drawingto see if that made me go "oh like that", checking if the bits of each value had a system, and now im here.

Titshit.
I dont know who made it like this, but i really dont want to make some static switch or if/else statement to process this directional trash. I want it flexible.

If you spotted a system to the numbers, please mail me a rock, and then tell me how i fix this.

Comments
  • 0
    Update: I now sent an email to Mojang, hoping for an explanation of why it is so illogical.
  • 3
    I don't think that they would change an established API, so you really prefer writing an email and a rant instead of a 6 lines switch case statement? 😂🤓
  • 0
    @GlabbichRulz i did it all. A method to rotate 90 degrees, which i just call the amount of times needed to rotate the proper amount of degrees.

    Its ugly asf tho.
    And no, i dont expect them to change anything, i just hope for literally any kind of response, either a "I dont know" or a "Its because blablabla" :P
  • 0
    Okay, i had to try myself :D

    3
    1 0
    2

    Converting to Bit does not help:

    11
    01 00
    10

    Sorting the Array by the indexes however leads to:

    N 3
    W 1
    E 0
    S 2

    —›

    E 0 (positive x-axis)
    W 1 (negative x-axis)
    S 2 (positive z-axis)
    N 3 (negative z-axis)

    I added my guess in parantheses :D
    Coordinates in minecraft are based on a grid where three lines or axes intersect at the origin point - x and z horizonally and y vertically, which is irrelevant for compass positions :)
    See https://minecraft.gamepedia.com/Coo...
  • 0
    @GlabbichRulz that may make sense, but only for users, which doesnt know about the numbers anyway.

    Programmatically it still doesnt provide a way to write a piece of flexible code, like adding or subtracting 1 to rotate 90 degrees.
  • 0
    If it that bad create your own enum and a translator...
  • 0
    @LastDigitOfPi yeah, but i wish i had ideas for other things than Minecraft plugins :P
  • 0
    @hubiruchi i just feel like it shouldnt be that complicated
  • 0
    You could do the following if booleens can be interpreted as 0 and 1 or type cast them to ints.

    current = 2*(current == 0) + 3*(current == 1) + 1*(current == 2) + 0*(current == 3)

    There's probably a better way to do it though than that that is more readable like what you did.

    Probably could use ENUM or const or similar in the comparisons to make it clear the 0,1,2,3 are directions, e.g.

    NORTH = 3
    (current == NORTH)
  • 1
    @arcadesdude ive never seen anything like that code suggestion, using booleans like that. You opened my mind up a bit, thanks :)
  • 2
    @rasm945i thats funny because he is using booleans as a bit...
  • 0
Add Comment