Skip to content

Add global data attachments#5231

Open
DennisOchulor wants to merge 11 commits intoFabricMC:26.1from
DennisOchulor:global-att
Open

Add global data attachments#5231
DennisOchulor wants to merge 11 commits intoFabricMC:26.1from
DennisOchulor:global-att

Conversation

@DennisOchulor
Copy link
Contributor

This PR adds global (server-wide) data attachments that are not tied to any specific Level.

Global attachments are stored in MinecraftServer and ClientPacketListener on the server and client respectively. The GlobalAttachments target can be obtained via Level.globalAttachments() on either side and also MinecraftServer.globalAttachments() on the server for convenience.

public static final int MAX_PADDING_SIZE_IN_BYTES = AttachmentTargetInfo.MAX_SIZE_IN_BYTES + MAX_IDENTIFIER_SIZE;
public static final int DEFAULT_MAX_DATA_SIZE;
public static final int DEFAULT_ATTACHMENT_SYNC_PACKET_SIZE;
private static final Set<ServerGamePacketListenerImpl> playerConnections = Collections.newSetFromMap(new IdentityHashMap<>());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just taking a quick look atm and this doesnt seem ideal to me, why is this needed? Its likely going to cause issues when multiple servers are ran from the same process. (Something we do for client tests, and technically possible to have multiple servers in one process).

I think it would be best if this could use vanilla's existing per server player list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reasoning is explained here

// We don't use PlayerLookup.all() because when a player respawns,
// there is a brief period where said player will not be in the server player list.
// If a global attachment is set then, the respawning player will never receive the update.

I thought of this given the recent similar problems with player respawning like in #5155, tho I had not considered multiple servers on the same JVM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed it to get all player connections from MinecraftServer now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants