Jump to content

[1.7.10] Door questions


Thornack

Recommended Posts

Hi so I am looking into the door class's func_150012_g function which I have renamed to be called rotateDoor as it seems to impart this functionality I think.

I have been trying to understand how func_150012_g works and so far I seem to have found some bizarre behaviour. in particular

boolean flag = (doorMetadata &  != 0;

I used

System.out.println("doorMetadata variable equals:" + doorMetadata); 

right below the flag and I get a value between 1 and 8 inclusive printed to the console every tick it seems. Where this number seems to only be zero if the door isnt placed in the world. If I change the value of the 8 to something other than 8 the door halves arent aligned anymore. also at a value of 12 the door halves are once again aligned and at a value of 18 they are aligned but the top half is on the bottom and the bottom half is at the top. I am having a hard time figuring out exactly how this method works. Any helpful comments are appreciated.

 

This is the function I am writing based off of func_150012_g to impart custom functionality to door rotation and change how doors open. But I need to understand them first

public int rotateDoor(IBlockAccess blockAccess, int blockXCoord, int blockYCoord, int blockZCoord)
    {
        int doorMetadata = blockAccess.getBlockMetadata(blockXCoord, blockYCoord, blockZCoord);
        // for some reason the 8 has to be there otherwise the door halves arent aligned. 
        // It isnt intuitive either at a value of 12 they are aligned again and also at a value of 18 but not as they should be
        int offsetDoorHalvesToAlign = 8;
        System.out.println("____________________________________" + doorMetadata);
        boolean flag = (doorMetadata & offsetDoorHalvesToAlign) != 0;
        int i1;
        int j1;

        if (flag)
        {
            i1 = blockAccess.getBlockMetadata(blockXCoord, blockYCoord - 1, blockZCoord);
            j1 = doorMetadata;
        }
        else
        {
            i1 = doorMetadata;
            j1 = blockAccess.getBlockMetadata(blockXCoord, blockYCoord + 1, blockZCoord);
        }

        boolean flag1 = (j1 & 1) != 0;
        return i1 & 7 | (flag ? 8 : 0) | (flag1 ? 16 : 0);
    }

Link to comment
Share on other sites

If I change the value of the 8 to something other than 8 the door halves arent aligned anymore.

 

No shit.

http://minecraft.gamepedia.com/Door#Block_data

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

The link goes to the wiki page, which details what the door's metadata does.

In this case, the 4th bit ("8") means "this block is the top half of the door."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.