forked from Nan1t/NanoLimbo
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # api/src/main/java/ua/nanit/limbo/connection/PacketSnapshots.java # api/src/main/java/ua/nanit/limbo/protocol/NbtMessage.java # api/src/main/java/ua/nanit/limbo/protocol/packets/play/PacketEmptyChunk.java # api/src/main/java/ua/nanit/limbo/protocol/packets/play/PacketGameEvent.java # api/src/main/java/ua/nanit/limbo/util/NbtMessageUtil.java # build.gradle
- Loading branch information
Showing
19 changed files
with
396 additions
and
73 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ua.nanit.limbo.protocol; | ||
|
||
import net.kyori.adventure.nbt.BinaryTag; | ||
|
||
public class NbtMessage { | ||
|
||
private String json; | ||
private BinaryTag tag; | ||
|
||
public NbtMessage(String json, BinaryTag tag) { | ||
this.json = json; | ||
this.tag = tag; | ||
} | ||
|
||
public String getJson() { | ||
return json; | ||
} | ||
|
||
public void setJson(String json) { | ||
this.json = json; | ||
} | ||
|
||
public BinaryTag getTag() { | ||
return tag; | ||
} | ||
|
||
public void setTag(BinaryTag tag) { | ||
this.tag = tag; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
api/src/main/java/ua/nanit/limbo/protocol/packets/play/PacketEmptyChunk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ua.nanit.limbo.protocol.packets.play; | ||
|
||
import net.kyori.adventure.nbt.CompoundBinaryTag; | ||
import net.kyori.adventure.nbt.LongArrayBinaryTag; | ||
import ua.nanit.limbo.protocol.ByteMessage; | ||
import ua.nanit.limbo.protocol.PacketOut; | ||
import ua.nanit.limbo.protocol.registry.Version; | ||
|
||
public class PacketEmptyChunk implements PacketOut { | ||
|
||
private int x; | ||
private int z; | ||
|
||
public void setX(int x) { | ||
this.x = x; | ||
} | ||
|
||
public void setZ(int z) { | ||
this.z = z; | ||
} | ||
|
||
@Override | ||
public void encode(ByteMessage msg, Version version) { | ||
msg.writeInt(x); | ||
msg.writeInt(z); | ||
|
||
LongArrayBinaryTag longArrayTag = LongArrayBinaryTag.longArrayBinaryTag(new long[37]); | ||
CompoundBinaryTag tag = CompoundBinaryTag.builder() | ||
.put("MOTION_BLOCKING", longArrayTag).build(); | ||
CompoundBinaryTag rootTag = CompoundBinaryTag.builder() | ||
.put("root", tag).build(); | ||
msg.writeNamelessCompoundTag(rootTag); | ||
|
||
byte[] sectionData = new byte[]{0, 0, 0, 0, 0, 0, 1, 0}; | ||
msg.writeVarInt(sectionData.length * 16); | ||
for (int i = 0; i < 16; i++) { | ||
msg.writeBytes(sectionData); | ||
} | ||
|
||
msg.writeVarInt(0); | ||
|
||
byte[] lightData = new byte[]{1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 3, -1, -1, 0, 0}; | ||
msg.ensureWritable(lightData.length); | ||
msg.writeBytes(lightData, 1, lightData.length - 1); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
api/src/main/java/ua/nanit/limbo/protocol/packets/play/PacketGameEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ua.nanit.limbo.protocol.packets.play; | ||
|
||
import ua.nanit.limbo.protocol.ByteMessage; | ||
import ua.nanit.limbo.protocol.PacketOut; | ||
import ua.nanit.limbo.protocol.registry.Version; | ||
|
||
public class PacketGameEvent implements PacketOut { | ||
|
||
private byte type; | ||
private float value; | ||
|
||
public void setType(byte type) { | ||
this.type = type; | ||
} | ||
|
||
public void setValue(float value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public void encode(ByteMessage msg, Version version) { | ||
msg.writeByte(type); | ||
msg.writeFloat(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.