Skip to content

Commit

Permalink
Revert ClientTagManager to immediately resolve
Browse files Browse the repository at this point in the history
In the future, it would be cool to make this back into an async operation, but I would have to find some places for mixins to make all resources wait until tags are done
  • Loading branch information
dhyces committed Jun 13, 2024
1 parent beb89a1 commit c25ea8a
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.DependencySorter;
import net.minecraft.util.GsonHelper;
import net.minecraft.util.Unit;
import net.minecraft.util.profiling.ProfilerFiller;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
Expand Down Expand Up @@ -72,17 +73,13 @@ public CompletableFuture<Void> reload(PreparationBarrier pPreparationBarrier, Re
return load(pResourceManager, TrimmedClient.getStaticHolder(), false).thenCompose(pPreparationBarrier::wait).thenRun(() -> Trimmed.logInDev("Client tags loaded!"));
}

private static CompletableFuture<Void> load(ResourceManager resourceManager, GameRegistryHolder registryHolder, boolean onlyLoadSynced) {
return CompletableFuture.allOf(StreamSupport.stream(KeyResolvers.getEntries().spliterator(), false)
.map(entry -> CompletableFuture.runAsync(() -> {
// if onlyLoadSynced, only resolveTags if isSynced and requiresActiveWorld
// otherwise, load if not requiresActiveWorld or isSynced
if (onlyLoadSynced ? entry.getValue().requiresActiveWorld() && registryHolder.isSynced() : !entry.getValue().requiresActiveWorld() || registryHolder.isSynced()) {
resolveTags(entry.getKey(), entry.getValue(), resourceManager, registryHolder.registryAccess().createSerializationContext(JsonOps.INSTANCE));
}
}))
.toArray(CompletableFuture[]::new)
);
private static CompletableFuture<Unit> load(ResourceManager resourceManager, GameRegistryHolder registryHolder, boolean onlyLoadSynced) {
for (Map.Entry<ResourceLocation, KeyResolver<?>> entry : KeyResolvers.getEntries()) {
if (onlyLoadSynced ? entry.getValue().requiresActiveWorld() && registryHolder.isSynced() : !entry.getValue().requiresActiveWorld() || registryHolder.isSynced()) {
resolveTags(entry.getKey(), entry.getValue(), resourceManager, registryHolder.registryAccess().createSerializationContext(JsonOps.INSTANCE));
}
}
return CompletableFuture.completedFuture(Unit.INSTANCE);
}

private static <T> void resolveTags(ResourceLocation registryId, KeyResolver<T> keyResolver, ResourceManager resourceManager, DynamicOps<JsonElement> jsonOps) {
Expand Down

0 comments on commit c25ea8a

Please sign in to comment.