поправлена работа с pool object в сериализации чанков
This commit is contained in:
@@ -6,6 +6,7 @@ import lombok.Getter;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import mc.protocol.buffer.NetByteBuf;
|
import mc.protocol.buffer.NetByteBuf;
|
||||||
import mc.protocol.packets.ServerSidePacket;
|
import mc.protocol.packets.ServerSidePacket;
|
||||||
|
import mc.protocol.pool.ProtocolObjectPool;
|
||||||
import mc.protocol.utils.Bit13LongArray;
|
import mc.protocol.utils.Bit13LongArray;
|
||||||
import mc.protocol.utils.HalfByteArray;
|
import mc.protocol.utils.HalfByteArray;
|
||||||
import mc.protocol.utils.NibbleArray;
|
import mc.protocol.utils.NibbleArray;
|
||||||
@@ -86,10 +87,6 @@ public class ChunkDataPacket implements ServerSidePacket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSelf(NetByteBuf netByteBuf) {
|
public void writeSelf(NetByteBuf netByteBuf) {
|
||||||
/*
|
|
||||||
TODO необходимо наладить работу objectpool при записи пакета
|
|
||||||
*/
|
|
||||||
|
|
||||||
netByteBuf.writeInt(chunk.getX()); // Chunk X
|
netByteBuf.writeInt(chunk.getX()); // Chunk X
|
||||||
netByteBuf.writeInt(chunk.getZ()); // Chunk Z
|
netByteBuf.writeInt(chunk.getZ()); // Chunk Z
|
||||||
|
|
||||||
@@ -104,6 +101,8 @@ public class ChunkDataPacket implements ServerSidePacket {
|
|||||||
|
|
||||||
netByteBuf.writeVarInt(0); // Number of block entities
|
netByteBuf.writeVarInt(0); // Number of block entities
|
||||||
// Block entities (NBT's)
|
// Block entities (NBT's)
|
||||||
|
|
||||||
|
ProtocolObjectPool.getNetByteBufPool().returnObject(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AvailableSections createAvailableSections() {
|
private AvailableSections createAvailableSections() {
|
||||||
@@ -124,10 +123,8 @@ public class ChunkDataPacket implements ServerSidePacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NetByteBuf createDataStructure(int maxHeight, boolean fillBiomes) {
|
private NetByteBuf createDataStructure(int maxHeight, boolean fillBiomes) {
|
||||||
// NetByteBuf dataStructure = ProtocolObjectPool.getNetByteBufPool().borrowObject().setByteBuf(Unpooled.buffer());
|
NetByteBuf dataStructure = ProtocolObjectPool.getNetByteBufPool().borrowObject().setByteBuf(Unpooled.buffer());
|
||||||
NetByteBuf dataStructure = new NetByteBuf().setByteBuf(Unpooled.buffer());
|
NetByteBuf biomes = fillBiomes ? ProtocolObjectPool.getNetByteBufPool().borrowObject().setByteBuf(Unpooled.buffer()) : null;
|
||||||
// NetByteBuf biomes = fillBiomes ? ProtocolObjectPool.getNetByteBufPool().borrowObject().setByteBuf(Unpooled.buffer()) : null;
|
|
||||||
NetByteBuf biomes = fillBiomes ? new NetByteBuf().setByteBuf(Unpooled.buffer()) : null;
|
|
||||||
|
|
||||||
for (int h = 0; h < maxHeight; h++) {
|
for (int h = 0; h < maxHeight; h++) {
|
||||||
ChunkSection section = chunk.getSection(h);
|
ChunkSection section = chunk.getSection(h);
|
||||||
@@ -135,19 +132,21 @@ public class ChunkDataPacket implements ServerSidePacket {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataStructure.writeBytes(createData(section, biomes)); // Data
|
NetByteBuf data = createData(section, biomes);
|
||||||
|
dataStructure.writeBytes(data); // Data
|
||||||
|
ProtocolObjectPool.getNetByteBufPool().returnObject(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fillBiomes) {
|
if (fillBiomes) {
|
||||||
dataStructure.writeBytes(biomes); // Biomes
|
dataStructure.writeBytes(biomes); // Biomes
|
||||||
|
ProtocolObjectPool.getNetByteBufPool().returnObject(biomes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataStructure;
|
return dataStructure;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NetByteBuf createData(ChunkSection section, NetByteBuf biomes) {
|
private NetByteBuf createData(ChunkSection section, NetByteBuf biomes) {
|
||||||
// NetByteBuf data = ProtocolObjectPool.getNetByteBufPool().borrowObject().setByteBuf(Unpooled.buffer());
|
NetByteBuf data = ProtocolObjectPool.getNetByteBufPool().borrowObject().setByteBuf(Unpooled.buffer());
|
||||||
NetByteBuf data = new NetByteBuf().setByteBuf(Unpooled.buffer());
|
|
||||||
|
|
||||||
NibbleArray blockLight = new HalfByteArray(2048);
|
NibbleArray blockLight = new HalfByteArray(2048);
|
||||||
NibbleArray skyLight = new HalfByteArray(2048);
|
NibbleArray skyLight = new HalfByteArray(2048);
|
||||||
|
|||||||
Reference in New Issue
Block a user