Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
public class MixinMinecraftServer {

/*
* Force the server to use the pending tags we gathered instead of trying
* to load them from the resource pack repository where it doesn't exist
* Keep the tags already installed on replay registries instead of trying
* to load them from the replay server's empty datapack repository.
*/

@WrapOperation(method = "method_29437", at = @At(value = "INVOKE", target = "Lnet/minecraft/tags/TagLoader;loadTagsForExistingRegistries(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/core/RegistryAccess;)Ljava/util/List;"))
public List<Registry.PendingTags<?>> loadTagsForExistingRegistries(ResourceManager resourceManager, RegistryAccess registryAccess, Operation<List<Registry.PendingTags<?>>> original) {
if ((Object) this instanceof ReplayServer replayServer && replayServer.overridePendingTags != null) {
return replayServer.overridePendingTags;
if ((Object) this instanceof ReplayServer) {
return List.of();
}
return original.call(resourceManager, registryAccess);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public void flushPendingConfiguration() {
this.pendingResetChat = false;
}

List<Registry.PendingTags<?>> pendingTags = new ArrayList<>();

if (this.pendingTags != null && !this.pendingTags.isEmpty()) {
this.pendingTags.forEach((resourceKey, networkPayload) -> {
var registry = this.replayServer.registryAccess().lookupOrThrow(resourceKey);
Expand All @@ -91,9 +89,8 @@ public void flushPendingConfiguration() {
this.pendingRegistryMap.put(resourceKey, new RegistryDataLoader.NetworkedRegistryData(entry.elements(), networkPayload));
}
}
pendingTags.add(registry.prepareTagReload(loadResult));
registry.prepareTagReload(loadResult).apply();
});
pendingTags.forEach(Registry.PendingTags::apply);
sendTags = true;
this.pendingTags = null;
}
Expand All @@ -103,10 +100,10 @@ public void flushPendingConfiguration() {
if (this.pendingRegistryMap != null && !this.pendingRegistryMap.isEmpty()) {
if (this.packRepository != null) {
try (CloseableResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, this.packRepository.openAllSelected())) {
synchronizeRegistries = tryUpdateRegistries(pendingTags, resourceManager);
synchronizeRegistries = tryUpdateRegistries(resourceManager);
}
} else {
synchronizeRegistries = tryUpdateRegistries(pendingTags, ResourceProvider.EMPTY);
synchronizeRegistries = tryUpdateRegistries(ResourceProvider.EMPTY);
}
}

Expand All @@ -120,7 +117,7 @@ public void flushPendingConfiguration() {
return;
}

this.replayServer.updateRegistry(currentFeatureFlags, pendingTags, initialPackets, configurationTasks, this.knownPackIds);
this.replayServer.updateRegistry(currentFeatureFlags, initialPackets, configurationTasks, this.knownPackIds);

// Remove all players
for (ServerPlayer player : new ArrayList<>(this.replayServer.getPlayerList().getPlayers())) {
Expand All @@ -137,11 +134,11 @@ public void flushPendingConfiguration() {
this.replayServer.loadLevel();
}

private boolean tryUpdateRegistries(List<Registry.PendingTags<?>> pendingTags, ResourceProvider resourceProvider) {
private boolean tryUpdateRegistries(ResourceProvider resourceProvider) {
Map<ResourceKey<? extends Registry<?>>, RegistryDataLoader.NetworkedRegistryData> entries = this.pendingRegistryMap;
this.pendingRegistryMap = null;

List<HolderLookup.RegistryLookup<?>> updatedLookups = TagLoader.buildUpdatedLookups(this.replayServer.registryAccess(), pendingTags);
List<HolderLookup.RegistryLookup<?>> updatedLookups = TagLoader.buildUpdatedLookups(this.replayServer.registryAccess(), List.of());

RegistryAccess.Frozen synchronizedRegistries;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.server.IntegratedServer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.Connection;
import net.minecraft.network.RegistryFriendlyByteBuf;
Expand Down Expand Up @@ -225,9 +224,7 @@ public FlashbackMeta getMetadata() {
return this.metadata;
}

public List<Registry.PendingTags<?>> overridePendingTags = null;

public void updateRegistry(FeatureFlagSet featureFlagSet, List<Registry.PendingTags<?>> pendingTags,
public void updateRegistry(FeatureFlagSet featureFlagSet,
List<Packet<? super ClientConfigurationPacketListener>> initialPackets,
List<ConfigurationTask> configurationTasks,
@Nullable Collection<String> knownPackIds) {
Expand All @@ -251,7 +248,6 @@ public void updateRegistry(FeatureFlagSet featureFlagSet, List<Registry.PendingT
));
}

overridePendingTags = pendingTags;
this.reloadResources(knownPackIds != null ? knownPackIds : this.getPackRepository().getSelectedIds());

this.gamePacketCodec = GameProtocols.CLIENTBOUND_TEMPLATE.bind(RegistryFriendlyByteBuf.decorator(this.registryAccess())).codec();
Expand Down