imported>SirCmpwn |
imported>Fenhl |
| (14 intermediate revisions by 6 users not shown) |
| Line 1: |
Line 1: |
| All types in Java (and as such Minecraft) are [http://en.wikipedia.org/wiki/Endianness#Big-endian big-endian], that is, the most significant byte comes first. The majority of everyday computers are little endian, and using most programming languages will require converting big endian values to little endian.
| | #REDIRECT [[Data types]] |
| | |
| These data formats are identical to those provided by the Java classes [http://download.oracle.com/javase/1.4.2/docs/api/java/io/DataInputStream.html DataInputStream] and [http://download.oracle.com/javase/1.4.2/docs/api/java/io/DataOutputStream.html DataOutputStream].
| |
| | |
| {| class="wikitable"
| |
| |- class="row0"
| |
| | class="col0" |
| |
| ! class="col1" | Size
| |
| ! class="col2" | Range
| |
| ! class="col3" | Notes
| |
| |- class="row1"
| |
| ! class="col0 centeralign" | byte
| |
| | class="col1 centeralign" | 1
| |
| | class="col2" | -128 to 127
| |
| | class="col3" | Signed, two's complement
| |
| |- class="row2"
| |
| ! class="col0 centeralign" | short
| |
| | class="col1 centeralign" | 2
| |
| | class="col2" | -32768 to 32767
| |
| | class="col3" | Signed, two's complement
| |
| |- class="row3"
| |
| ! class="col0 centeralign" | int
| |
| | class="col1 centeralign" | 4
| |
| | class="col2" | -2147483648 to 2147483647
| |
| | class="col3" | Signed, two's complement
| |
| |- class="row4"
| |
| ! class="col0 centeralign" | long
| |
| | class="col1 centeralign" | 8
| |
| | class="col2" | -9223372036854775808 to 9223372036854775807
| |
| | class="col3" | Signed, two's complement
| |
| |- class="row5"
| |
| ! class="col0 centeralign" | float
| |
| | class="col1 centeralign" | 4
| |
| | class="col2" |
| |
| See [http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3 this]
| |
| | class="col3" | Single-precision 32-bit IEEE 754 floating point
| |
| |- class="row6"
| |
| ! class="col0 centeralign" | double
| |
| | class="col1 centeralign" | 8
| |
| | class="col2" |
| |
| See [http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3 this]
| |
| | class="col3" | Double-precision 64-bit IEEE 754 floating point
| |
| |- class="row7"
| |
| ! class="col0 centeralign" | string
| |
| | class="col1 centeralign" | ≥ 2 <br />≤ 240
| |
| | class="col2" | N/A
| |
| | class="col3" | [http://en.wikipedia.org/wiki/UTF-16/UCS-2 UCS-2] string, big-endian. Prefixed by a short containing the length of the string in characters. UCS-2 consists of 16-bit words, each of which represent a Unicode code point between U+0000 and U+FFFF inclusive.
| |
| |- class="row8"
| |
| ! class="col0 centeralign" | bool
| |
| | class="col1 centeralign" | 1
| |
| | class="col2" | 0 or 1
| |
| | class="col3" | Value can be either True (0x01) or False (0x00)
| |
| |- class="row9"
| |
| ! class="col0 centeralign" | metadata
| |
| | class="col1 centeralign" | Varies
| |
| | class="col2" | See [[Entities#Entity_Metadata_Format|this]]
| |
| | class="Col3" |
| |
| |}
| |
| | |
| Some data may be stored as an "absolute integer", which is a more precise kind of integer, and a less precise kind of double. The conversion from double to absolute integer is like so:
| |
| | |
| abs_int = (int)double * 32;
| |
| | |
| And back again:
| |
| | |
| double = (double)abs_int / 32;
| |
| | |
| [[Category:Protocol Details]]
| |
| [[Category:Minecraft Modern]]
| |