Skip to content

Commit

Permalink
Remove map cache
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Ferguson committed Apr 16, 2024
1 parent a24f684 commit 0e81adb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
@Setter
private ItemMappings itemMappings;

private final Long2ObjectMap<ClientboundMapItemDataPacket> storedMaps = new Long2ObjectOpenHashMap<>();

/**
* Required to decode biomes correctly.
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class JavaMapItemDataTranslator extends PacketTranslator<ClientboundMapIt
@Override
public void translate(GeyserSession session, ClientboundMapItemDataPacket packet) {
org.cloudburstmc.protocol.bedrock.packet.ClientboundMapItemDataPacket mapItemDataPacket = new org.cloudburstmc.protocol.bedrock.packet.ClientboundMapItemDataPacket();
boolean shouldStore = false;

mapItemDataPacket.setUniqueMapId(packet.getMapId());
mapItemDataPacket.setDimensionId(DimensionUtils.javaToBedrock(session.getDimension()));
Expand All @@ -61,11 +60,6 @@ public void translate(GeyserSession session, ClientboundMapItemDataPacket packet
mapItemDataPacket.setWidth(data.getColumns());
mapItemDataPacket.setHeight(data.getRows());

// We have a full map image, this usually only happens on spawn for the initial image
if (mapItemDataPacket.getWidth() == 128 && mapItemDataPacket.getHeight() == 128) {
shouldStore = true;
}

// Every int entry is an ARGB color
int[] colors = new int[data.getData().length];

Expand All @@ -87,12 +81,11 @@ public void translate(GeyserSession session, ClientboundMapItemDataPacket packet
id++;
}

// Store the map to send when the client requests it, as bedrock expects the data after a MapInfoRequestPacket
if (shouldStore) {
session.getStoredMaps().put(mapItemDataPacket.getUniqueMapId(), mapItemDataPacket);
// Client will ignore if sent too early
if (session.isSentSpawnPacket()) {
session.sendUpstreamPacket(mapItemDataPacket);
} else {
session.getUpstream().queuePostStartGamePacket(mapItemDataPacket);
}

// Send anyway just in case
session.sendUpstreamPacket(mapItemDataPacket);
}
}

0 comments on commit 0e81adb

Please sign in to comment.