Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
package org.geysermc.geyser.level.chunk;

import org.geysermc.mcprotocollib.protocol.data.game.chunk.DataPalette;
import org.geysermc.mcprotocollib.protocol.data.game.level.LightUpdateData;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityInfo;

/**
* Acts as a lightweight chunk class that doesn't store biomes, heightmaps or block entities.
* Acts as a lightweight chunk class that doesn't store biomes.
*/
public record GeyserChunk(DataPalette[] sections) {
public record GeyserChunk(DataPalette[] sections, BlockEntityInfo[][] blockEntities, LightUpdateData lightData) {

public static GeyserChunk from(DataPalette[] sections) {
return new GeyserChunk(sections);
public static GeyserChunk from(DataPalette[] sections, BlockEntityInfo[][] blockEntities, LightUpdateData lightData) {
return new GeyserChunk(sections, blockEntities, lightData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
import org.cloudburstmc.protocol.bedrock.packet.SetEntityMotionPacket;
import org.cloudburstmc.protocol.bedrock.packet.SettingsCommandPacket;
import org.cloudburstmc.protocol.bedrock.packet.SimpleEventPacket;
import org.cloudburstmc.protocol.bedrock.packet.SubChunkRequestPacket;
import org.cloudburstmc.protocol.bedrock.packet.SubClientLoginPacket;
import org.cloudburstmc.protocol.common.util.VarInts;

Expand Down Expand Up @@ -265,7 +264,6 @@ static BedrockCodec processCodec(BedrockCodec codec) {
// Illegal unusued serverbound packets that relate to unused features
.updateSerializer(ClientCacheBlobStatusPacket.class, ILLEGAL_SERIALIZER)
.updateSerializer(SubClientLoginPacket.class, ILLEGAL_SERIALIZER)
.updateSerializer(SubChunkRequestPacket.class, ILLEGAL_SERIALIZER)
.updateSerializer(GameTestRequestPacket.class, ILLEGAL_SERIALIZER)
// Ignored serverbound packets
.updateSerializer(ClientToServerHandshakePacket.class, IGNORED_SERIALIZER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.util.MathUtils;
import org.geysermc.mcprotocollib.protocol.data.game.chunk.DataPalette;
import org.geysermc.mcprotocollib.protocol.data.game.level.LightUpdateData;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityInfo;

public class ChunkCache {
private final boolean cache;
Expand All @@ -50,20 +52,20 @@ public ChunkCache(GeyserSession session) {
chunks = cache ? new Long2ObjectOpenHashMap<>() : null;
}

public void addToCache(int x, int z, DataPalette[] chunks) {
public void addToCache(int x, int z, DataPalette[] chunks, BlockEntityInfo[][] blockEntities, LightUpdateData lightData) {
if (!cache) {
return;
}

long chunkPosition = MathUtils.chunkPositionToLong(x, z);
GeyserChunk geyserChunk = GeyserChunk.from(chunks);
GeyserChunk geyserChunk = GeyserChunk.from(chunks, blockEntities, lightData);
this.chunks.put(chunkPosition, geyserChunk);
}

/**
* Doesn't check for cache enabled, so don't use this without checking that first!
*/
private GeyserChunk getChunk(int chunkX, int chunkZ) {
public GeyserChunk getChunk(int chunkX, int chunkZ) {
long chunkPosition = MathUtils.chunkPositionToLong(chunkX, chunkZ);
return chunks.getOrDefault(chunkPosition, null);
}
Expand Down
Loading
Loading