diff options
| author | Fuwn <[email protected]> | 2021-03-18 18:54:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-03-18 18:54:41 -0700 |
| commit | bc59a4b91b4f457f30356f31ad1a636774411470 (patch) | |
| tree | ec44109b9c72590e85d8d27750fe9cf6fa0de9b6 /src/jar/net/network/obj_id.md | |
| parent | chore: create contribution guidelines (diff) | |
| download | book-bc59a4b91b4f457f30356f31ad1a636774411470.tar.xz book-bc59a4b91b4f457f30356f31ad1a636774411470.zip | |
feat: many new pages
Diffstat (limited to 'src/jar/net/network/obj_id.md')
| -rw-r--r-- | src/jar/net/network/obj_id.md | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/jar/net/network/obj_id.md b/src/jar/net/network/obj_id.md new file mode 100644 index 0000000..a591366 --- /dev/null +++ b/src/jar/net/network/obj_id.md @@ -0,0 +1,66 @@ +# ObjID + +## Imports +- `java.io.IOException` + +## Fields +### `private int _shortObjID` + +### `private String _longObjID` + +## Constructors +```java +public ObjID(int id) { + this._shortObjID = id; + this._longObjID = null; +} + +public ObjID(String id) { + this._shortObjID = 0; + if (id.startsWith("!")) + id = id.substring(1); + this._longObjID = id; +} + +public ObjID() { + this._shortObjID = 0; + this._longObjID = null; +} +``` + +## Methods +### `public int shortID()` +Returns [`this._shortObjID`](#private-int-_shortobjid). + +### `public int longID()` +Returns [`this._longObjID`](#private-string-_longobjid). + +### `void parseNetData(`[`ServerOutputStream`](./server_output_stream.md)` o) throws IOException` +```java +if (this._longObjID != null) { + o.writeByte(0); + o.writeUTF(this._longObjID); +} else { + assert this._shortObjID == 1 || this._shortObjID >= 253; + o.writeByte(this._shortObjID); +} +``` + +TLDR; Returns the correct field? + +### `public String toString(WorldServer serv)` +```java +if (this._longObjID != null) + return this._longObjID; + +return String.valueOf(Integer.toString(this._shortObjID)) + + "[" + serv.getLongID(this) + "]"; +``` + +### `public String toString()` +```java +if (this._longObjID != null) + return this._longObjID; + +return "[#" + Integer.toString(this._shortObjID) + "]"; +``` |