Skip to content

Commit 38cef4f

Browse files
committed
more backporting
1 parent 178ddea commit 38cef4f

File tree

5 files changed

+103
-18
lines changed

5 files changed

+103
-18
lines changed

src/main/java/org/quiltmc/qsl/frozenblock/core/registry/impl/sync/server/DelayedPacketsHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
@ApiStatus.Internal
2727
public interface DelayedPacketsHolder {
2828
void frozenLib$setPacketList(List<ServerboundCustomPayloadPacket> packetList);
29-
List<Packet<?>> frozenLib$getPacketList();
29+
List<ServerboundCustomPayloadPacket> frozenLib$getPacketList();
3030
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2022 The Quilt Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.quiltmc.qsl.frozenblock.core.registry.mixin;
18+
19+
import net.minecraft.network.Connection;
20+
import net.minecraft.server.level.ServerPlayer;
21+
import net.minecraft.server.players.PlayerList;
22+
import org.quiltmc.qsl.frozenblock.core.registry.impl.sync.server.DelayedPacketsHolder;
23+
import org.spongepowered.asm.mixin.Mixin;
24+
import org.spongepowered.asm.mixin.injection.At;
25+
import org.spongepowered.asm.mixin.injection.Inject;
26+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
27+
28+
@Mixin(PlayerList.class)
29+
public class PlayerListMixin {
30+
31+
@Inject(method = "placeNewPlayer", at = @At("TAIL"))
32+
private void sendSync(Connection netManager, ServerPlayer player, CallbackInfo ci) {
33+
var delayedList = ((DelayedPacketsHolder) player).frozenLib$getPacketList();
34+
35+
if (delayedList != null) {
36+
for (var packet : delayedList) {
37+
packet.handle(player.connection);
38+
}
39+
}
40+
41+
((DelayedPacketsHolder) player).frozenLib$setPacketList(null);
42+
}
43+
}

src/main/java/org/quiltmc/qsl/frozenblock/core/registry/mixin/ServerLoginNetworkHandlerMixin.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
/*
2-
* Copyright 2023 FrozenBlock
3-
* This file is part of FrozenLib.
2+
* Copyright 2022 The Quilt Project
43
*
5-
* This program is free software; you can redistribute it and/or
6-
* modify it under the terms of the GNU Lesser General Public
7-
* License as published by the Free Software Foundation; either
8-
* version 3 of the License, or (at your option) any later version.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
97
*
10-
* This program is distributed in the hope that it will be useful,
11-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13-
* Lesser General Public License for more details.
8+
* http://www.apache.org/licenses/LICENSE-2.0
149
*
15-
* You should have received a copy of the GNU Lesser General Public License
16-
* along with this program; if not, see <https://www.gnu.org/licenses/>.
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
1715
*/
1816

1917
package org.quiltmc.qsl.frozenblock.core.registry.mixin;
@@ -37,19 +35,19 @@ public abstract class ServerLoginNetworkHandlerMixin {
3735

3836
@Shadow
3937
@Final
40-
public Connection connection;
38+
Connection connection;
4139

4240
@Shadow
4341
protected abstract void placeNewPlayer(ServerPlayer player);
4442

4543
@Unique
46-
private boolean quilt$continueJoining = false;
44+
private boolean frozenLib$continueJoining = false;
4745

4846
@Inject(method = "placeNewPlayer", at = @At("HEAD"), cancellable = true)
49-
private void quilt$applySyncHandler(ServerPlayer player, CallbackInfo ci) {
50-
if (!player.server.isSingleplayerOwner(player.getGameProfile()) && !this.quilt$continueJoining && ServerRegistrySync.shouldSync()) {
47+
private void applySyncHandler(ServerPlayer player, CallbackInfo ci) {
48+
if (!player.server.isSingleplayerOwner(player.getGameProfile()) && !this.frozenLib$continueJoining && ServerRegistrySync.shouldSync()) {
5149
this.connection.setListener(new ServerRegistrySyncNetworkHandler(player, this.connection, () -> {
52-
this.quilt$continueJoining = true;
50+
this.frozenLib$continueJoining = true;
5351
this.connection.setListener((PacketListener) this);
5452
this.placeNewPlayer(player);
5553
}));
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2022 The Quilt Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.quiltmc.qsl.frozenblock.core.registry.mixin;
18+
19+
import net.minecraft.network.protocol.Packet;
20+
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
21+
import net.minecraft.server.level.ServerPlayer;
22+
import org.quiltmc.qsl.frozenblock.core.registry.impl.sync.server.DelayedPacketsHolder;
23+
import org.spongepowered.asm.mixin.Mixin;
24+
import org.spongepowered.asm.mixin.Unique;
25+
import java.util.List;
26+
27+
@Mixin(ServerPlayer.class)
28+
public class ServerPlayerMixin implements DelayedPacketsHolder {
29+
30+
@Unique
31+
private List<ServerboundCustomPayloadPacket> frozenLib$delayedPackets;
32+
33+
@Override
34+
public void frozenLib$setPacketList(List<ServerboundCustomPayloadPacket> packetList) {
35+
this.frozenLib$delayedPackets = packetList;
36+
}
37+
38+
@Override
39+
public List<ServerboundCustomPayloadPacket> frozenLib$getPacketList() {
40+
return this.frozenLib$delayedPackets;
41+
}
42+
}

src/main/resources/mixin/frozenlib_quiltmc_registry.mixins.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
"BuiltInRegistriesMixin",
88
"ConnectionMixin",
99
"MappedRegistryMixin",
10+
"PlayerListMixin",
1011
"RegistryDataLoaderMixin",
1112
"ServerLoginNetworkHandlerMixin",
13+
"ServerPlayerMixin",
1214
"ServerStatusVersionMixin"
1315
],
1416
"injectors": {

0 commit comments

Comments
 (0)