Skip to content

Commit

Permalink
Fix packet syncing code sending the wrong object
Browse files Browse the repository at this point in the history
Parameters that accept object are annoying sometimes
  • Loading branch information
KnightMiner committed May 1, 2022
1 parent 91bbc68 commit 66db3f5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static List<JsonObject> getFileInAllDomainsAndPacks(ResourceManager manag
}

/** Sends the packet to the given player */
private static void sendPackets(ServerPlayer player, ISimplePacket[] packet) {
private static void sendPackets(ServerPlayer player, ISimplePacket[] packets) {
// on an integrated server, the modifier registries have a single instance on both the client and the server thread
// this means syncing is unneeded, and has the side-effect of recreating all the modifier instances (which can lead to unexpected behavior)
// as a result, integrated servers just mark fullyLoaded as true without syncing anything, side-effect is listeners may run twice on single player
Expand All @@ -167,7 +167,9 @@ private static void sendPackets(ServerPlayer player, ISimplePacket[] packet) {
if (!player.connection.getConnection().isMemoryConnection()) {
TinkerNetwork network = TinkerNetwork.getInstance();
PacketTarget target = PacketDistributor.PLAYER.with(() -> player);
network.send(target, packet);
for (ISimplePacket packet : packets) {
network.send(target, packet);
}
}
}

Expand Down

0 comments on commit 66db3f5

Please sign in to comment.