mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-27 05:44:39 +00:00
TU19: merge Minecraft.World/Network
This commit is contained in:
@@ -10,6 +10,11 @@
|
||||
#include "../../Level/Storage/DataLayer.h"
|
||||
#include "../../Level/Dimensions/Dimension.h"
|
||||
|
||||
#define BLOCK_REGION_UPDATE_FULLCHUNK 0x01
|
||||
#define BLOCK_REGION_UPDATE_ZEROHEIGHT \
|
||||
0x02 // added so we can still send a byte for ys, which really needs the
|
||||
// range 0-256
|
||||
|
||||
BlockRegionUpdatePacket::~BlockRegionUpdatePacket() { delete[] buffer.data; }
|
||||
|
||||
BlockRegionUpdatePacket::BlockRegionUpdatePacket() {
|
||||
@@ -81,7 +86,7 @@ BlockRegionUpdatePacket::BlockRegionUpdatePacket(int x, int y, int z, int xs,
|
||||
|
||||
void BlockRegionUpdatePacket::read(DataInputStream* dis) // throws IOException
|
||||
{
|
||||
bIsFullChunk = dis->readBoolean();
|
||||
uint8_t chunkFlags = dis->readByte();
|
||||
x = dis->readInt();
|
||||
y = dis->readShort();
|
||||
z = dis->readInt();
|
||||
@@ -89,6 +94,9 @@ void BlockRegionUpdatePacket::read(DataInputStream* dis) // throws IOException
|
||||
ys = dis->read() + 1;
|
||||
zs = dis->read() + 1;
|
||||
|
||||
bIsFullChunk = (chunkFlags & BLOCK_REGION_UPDATE_FULLCHUNK) ? true : false;
|
||||
if (chunkFlags & BLOCK_REGION_UPDATE_ZEROHEIGHT) ys = 0;
|
||||
|
||||
size = dis->readInt();
|
||||
levelIdx = (size >> 30) & 3;
|
||||
size &= 0x3fffffff;
|
||||
@@ -124,7 +132,11 @@ void BlockRegionUpdatePacket::read(DataInputStream* dis) // throws IOException
|
||||
void BlockRegionUpdatePacket::write(
|
||||
DataOutputStream* dos) // throws IOException
|
||||
{
|
||||
dos->writeBoolean(bIsFullChunk);
|
||||
uint8_t chunkFlags = 0;
|
||||
if (bIsFullChunk) chunkFlags |= BLOCK_REGION_UPDATE_FULLCHUNK;
|
||||
if (ys == 0) chunkFlags |= BLOCK_REGION_UPDATE_ZEROHEIGHT;
|
||||
|
||||
dos->writeByte(chunkFlags);
|
||||
dos->writeInt(x);
|
||||
dos->writeShort(y);
|
||||
dos->writeInt(z);
|
||||
|
||||
Reference in New Issue
Block a user