Jump to content

[1.5]The additional parameter in many World methods. Resolved?


Vogner

Recommended Posts

Seems like a bunch of block placement-related methods in World have gotten a fancy new parameter. I have a hard time with bitwise operators, would anybody mind explaining what this new parameter is used for?

 

Edit: If you check my post below, I at least describe how to understand the bitwise AND operator, which appears with greater frequency in 1.5 code

 

Edit 2: Regarding the setBlockAndMetadataWithUpdate method, the extra parameter supposedly specifies what, exactly, the "Update" part of the method does. See the post below by Turtle7878 for details.

Link to comment
Share on other sites

Alright, I got off my lazy ass and figured out how all the bitwise AND expressions work, since they seem to have popped up all over the place in 1.5 code.

 

Bitwise AND operations produce a value no greater than the second operand. You'll need a very basic understanding of reading binary numbers to understand this little lesson.

 

A bitwise and produces a 1 if both bits of two compared numbers are one, and a zero under any other circumstances. Here's how it works:

 

Let's try the expression (3 & 9)

 

1001 (9)

0011 (3)

______

0001

 

(3 & 9) becomes the binary number 0001, because the far right digit is the only one in which both values have a 1.

 

If you do the arithmetic, (x & 3) will always become either 0, 1, 2, or 3.

 

0 & 3 = 0

1 & 3 = 1

2 & 3 = 2

3 & 3 = 3

4 & 3 = 0

5 & 3 = 1

6 & 3 = 2

7 & 3 = 3

8 & 3 = 0

9 & 3 = 1

10 & 3 = 2

11 & 3 = 3

12 & 3 = 0

13 & 3 = 1

14 & 3 = 2

15 & 3 = 3

 

Obviously if you use (x & 4), or (x & 2), the resultant value will never exceed 4 or 2, respectively.

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.