summaryrefslogtreecommitdiffstats
path: root/src/Stream.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-09-15 17:46:56 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 03:39:31 +0100
commitdcd030c6ed41e080846d1d50cf82e1055ae48edd (patch)
tree791bf81717a40273fcd6f72b06d3eb24c0c94b1a /src/Stream.cpp
parent2017-09-03 (diff)
downloadAltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.gz
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.bz2
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.lz
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.xz
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.tar.zst
AltCraft-dcd030c6ed41e080846d1d50cf82e1055ae48edd.zip
Diffstat (limited to '')
-rw-r--r--src/Stream.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/Stream.cpp b/src/Stream.cpp
index 28680c6..665247d 100644
--- a/src/Stream.cpp
+++ b/src/Stream.cpp
@@ -118,14 +118,28 @@ long long StreamInput::ReadVarLong() {
}
std::vector<unsigned char> StreamInput::ReadEntityMetadata() {
+ LOG(FATAL) << "Reading EntityMetadata is not implemented";
return std::vector<unsigned char>();
}
-std::vector<unsigned char> StreamInput::ReadSlot() {
- return std::vector<unsigned char>();
+SlotData StreamInput::ReadSlot() {
+ SlotData slot;
+ slot.BlockId = ReadShort();
+
+ if (slot.BlockId == -1)
+ return slot;
+
+ slot.ItemCount = ReadByte();
+ slot.ItemDamage = ReadShort();
+
+ if (ReadByte() != 0)
+ throw std::runtime_error("Slot data with NBT not supported");
+
+ return slot;
}
std::vector<unsigned char> StreamInput::ReadNbtTag() {
+ LOG(FATAL) << "Reading NBT is not implemented";
return std::vector<unsigned char>();
}
@@ -255,8 +269,13 @@ void StreamOutput::WriteEntityMetadata(std::vector<unsigned char> value) {
LOG(FATAL) << "Used unimplemented WriteEntityMetadata: " << value.size();
}
-void StreamOutput::WriteSlot(std::vector<unsigned char> value) {
- LOG(FATAL) << "Used unimplemented WriteSlot " << value.size();
+void StreamOutput::WriteSlot(SlotData value) {
+ WriteShort(value.BlockId);
+ if (value.BlockId == -1)
+ return;
+ WriteByte(value.ItemCount);
+ WriteShort(value.ItemDamage);
+ WriteUByte(0);
}
void StreamOutput::WriteNbtTag(std::vector<unsigned char> value) {