use of com.nukkitx.protocol.bedrock.packet.PositionTrackingDBServerBroadcastPacket in project Geyser by GeyserMC.
the class BedrockPositionTrackingDBClientRequestTranslator method translate.
@Override
public void translate(GeyserSession session, PositionTrackingDBClientRequestPacket packet) {
PositionTrackingDBServerBroadcastPacket broadcastPacket = new PositionTrackingDBServerBroadcastPacket();
broadcastPacket.setTrackingId(packet.getTrackingId());
// Fetch the stored lodestone
LodestoneCache.LodestonePos pos = session.getLodestoneCache().getPos(packet.getTrackingId());
// If we don't have data for that ID tell the client its not found
if (pos == null) {
broadcastPacket.setAction(PositionTrackingDBServerBroadcastPacket.Action.NOT_FOUND);
session.sendUpstreamPacket(broadcastPacket);
return;
}
broadcastPacket.setAction(PositionTrackingDBServerBroadcastPacket.Action.UPDATE);
// Build the NBT data for the update
NbtMapBuilder builder = NbtMap.builder();
builder.putInt("dim", DimensionUtils.javaToBedrock(pos.dimension()));
builder.putString("id", "0x" + String.format("%08X", packet.getTrackingId()));
// Not sure what this is for
builder.putByte("version", (byte) 1);
// Not sure what this is for
builder.putByte("status", (byte) 0);
// Build the position for the update
builder.putList("pos", NbtType.INT, pos.x(), pos.y(), pos.z());
broadcastPacket.setTag(builder.build());
session.sendUpstreamPacket(broadcastPacket);
}
Aggregations