Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add core:resource_loader
Browse files Browse the repository at this point in the history
OroArmor committed Sep 27, 2024
1 parent 607a1d4 commit 1ea68f5
Showing 44 changed files with 119 additions and 2,739 deletions.
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@

import java.util.List;

import org.quiltmc.qsl.resource.loader.impl.QuiltBuiltinPackProfile;

import net.minecraft.component.ComponentType;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.registry.RegistryKey;
@@ -26,9 +28,7 @@

import net.fabricmc.fabric.api.item.v1.EnchantmentEvents;
import net.fabricmc.fabric.api.item.v1.EnchantmentSource;
import net.fabricmc.fabric.impl.resource.loader.BuiltinModResourcePackSource;
import net.fabricmc.fabric.impl.resource.loader.FabricResource;
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator;
import net.fabricmc.fabric.mixin.item.EnchantmentBuilderAccessor;

public class EnchantmentUtil {
@@ -65,7 +65,7 @@ public static EnchantmentSource determineSource(Resource resource) {

if (packSource == ResourcePackSource.BUILTIN) {
return EnchantmentSource.VANILLA;
} else if (packSource == ModResourcePackCreator.RESOURCE_PACK_SOURCE || packSource instanceof BuiltinModResourcePackSource) {
} else if (packSource instanceof QuiltBuiltinPackProfile.BuiltinPackSource) {
return EnchantmentSource.MOD;
}
}
4 changes: 4 additions & 0 deletions fabric-loot-api-v3/build.gradle
Original file line number Diff line number Diff line change
@@ -4,3 +4,7 @@ moduleDependencies(project, [
'fabric-api-base',
'fabric-resource-loader-v0'
])

dependencies {
modImplementation getQslModule("core", "resource_loader")
}
Original file line number Diff line number Diff line change
@@ -19,14 +19,14 @@
import java.util.HashMap;
import java.util.Map;

import org.quiltmc.qsl.resource.loader.impl.QuiltBuiltinPackProfile;

import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourcePackSource;
import net.minecraft.util.Identifier;

import net.fabricmc.fabric.api.loot.v3.LootTableSource;
import net.fabricmc.fabric.impl.resource.loader.BuiltinModResourcePackSource;
import net.fabricmc.fabric.impl.resource.loader.FabricResource;
import net.fabricmc.fabric.impl.resource.loader.ModResourcePackCreator;

public final class LootUtil {
public static final ThreadLocal<Map<Identifier, LootTableSource>> SOURCES = ThreadLocal.withInitial(HashMap::new);
@@ -37,7 +37,7 @@ public static LootTableSource determineSource(Resource resource) {

if (packSource == ResourcePackSource.BUILTIN) {
return LootTableSource.VANILLA;
} else if (packSource == ModResourcePackCreator.RESOURCE_PACK_SOURCE || packSource instanceof BuiltinModResourcePackSource) {
} else if (packSource instanceof QuiltBuiltinPackProfile.BuiltinPackSource) {
return LootTableSource.MOD;
}
}
4 changes: 4 additions & 0 deletions fabric-resource-loader-v0/build.gradle
Original file line number Diff line number Diff line change
@@ -9,3 +9,7 @@ testDependencies(project, [
':fabric-api-base',
':fabric-resource-loader-v0'
])

dependencies {
modApi getQslModule("core", "resource_loader")
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -3,14 +3,8 @@
"package": "net.fabricmc.fabric.mixin.resource.loader.client",
"compatibilityLevel": "JAVA_17",
"client": [
"CreateWorldScreenMixin",
"FontManagerMixin",
"GameOptionsMixin",
"KeyedResourceReloadListenerClientMixin",
"ResourcePackOrganizerMixin",
"VanillaResourcePackProviderMixin",
"GameOptionsWriteVisitorMixin",
"ClientDataPackManagerMixin"
"KeyedResourceReloadListenerClientMixin"
],
"injectors": {
"defaultRequire": 1
Original file line number Diff line number Diff line change
@@ -30,8 +30,11 @@
* themselves.
*
* @see ResourceReloadListenerKeys
*
* @deprecated see {@link org.quiltmc.qsl.resource.loader.api.reloader.IdentifiableResourceReloader IdentifiableResourceReloader}
*/
public interface IdentifiableResourceReloadListener extends ResourceReloader {
@Deprecated
public interface IdentifiableResourceReloadListener extends ResourceReloader, org.quiltmc.qsl.resource.loader.api.reloader.IdentifiableResourceReloader {
/**
* @return The unique identifier of this listener.
*/
@@ -45,4 +48,9 @@ public interface IdentifiableResourceReloadListener extends ResourceReloader {
default Collection<Identifier> getFabricDependencies() {
return Collections.emptyList();
}

@Override
default Identifier getQuiltId() {
return this.getFabricId();
}
}
Original file line number Diff line number Diff line change
@@ -22,7 +22,10 @@

/**
* Interface implemented by mod-provided resource packs.
*
* @deprecated see {@link org.quiltmc.qsl.resource.loader.api.QuiltPack QuiltPack}
*/
@Deprecated
public interface ModResourcePack extends ResourcePack {
/**
* @return The ModMetadata object associated with the mod providing this
Original file line number Diff line number Diff line change
@@ -31,7 +31,10 @@

/**
* Helper for working with {@link ResourceManager} instances, and other resource loader generalities.
*
* @deprecated see {@link org.quiltmc.qsl.resource.loader.api.ResourceLoader ResourceLoader}
*/
@Deprecated
@ApiStatus.NonExtendable
public interface ResourceManagerHelper {
/**
@@ -89,7 +92,8 @@ static ResourceManagerHelper get(ResourceType type) {
* @return {@code true} if successfully registered the resource pack, else {@code false}
*/
static boolean registerBuiltinResourcePack(Identifier id, ModContainer container, ResourcePackActivationType activationType) {
return ResourceManagerHelperImpl.registerBuiltinResourcePack(id, "resourcepacks/" + id.getPath(), container, activationType);
org.quiltmc.loader.api.ModContainer quiltContainer = org.quiltmc.loader.api.QuiltLoader.getModContainer(container.getMetadata().getId()).get();
return org.quiltmc.qsl.resource.loader.api.ResourceLoader.registerBuiltinPack(id, quiltContainer, activationType.toQuilt());
}

/**
@@ -110,7 +114,8 @@ static boolean registerBuiltinResourcePack(Identifier id, ModContainer container
* @return {@code true} if successfully registered the resource pack, else {@code false}
*/
static boolean registerBuiltinResourcePack(Identifier id, ModContainer container, Text displayName, ResourcePackActivationType activationType) {
return ResourceManagerHelperImpl.registerBuiltinResourcePack(id, "resourcepacks/" + id.getPath(), container, displayName, activationType);
org.quiltmc.loader.api.ModContainer quiltContainer = org.quiltmc.loader.api.QuiltLoader.getModContainer(container.getMetadata().getId()).get();
return org.quiltmc.qsl.resource.loader.api.ResourceLoader.registerBuiltinPack(id, quiltContainer, activationType.toQuilt(), displayName);
}

/**
@@ -133,7 +138,8 @@ static boolean registerBuiltinResourcePack(Identifier id, ModContainer container
*/
@Deprecated
static boolean registerBuiltinResourcePack(Identifier id, ModContainer container, String displayName, ResourcePackActivationType activationType) {
return ResourceManagerHelperImpl.registerBuiltinResourcePack(id, "resourcepacks/" + id.getPath(), container, Text.literal(displayName), activationType);
org.quiltmc.loader.api.ModContainer quiltContainer = org.quiltmc.loader.api.QuiltLoader.getModContainer(container.getMetadata().getId()).get();
return org.quiltmc.qsl.resource.loader.api.ResourceLoader.registerBuiltinPack(id, quiltContainer, activationType.toQuilt(), Text.literal(displayName));
}

/**
@@ -159,7 +165,13 @@ static boolean registerBuiltinResourcePack(Identifier id, ModContainer container
*/
@Deprecated
static boolean registerBuiltinResourcePack(Identifier id, String subPath, ModContainer container, boolean enabledByDefault) {
return ResourceManagerHelperImpl.registerBuiltinResourcePack(id, subPath, container,
enabledByDefault ? ResourcePackActivationType.DEFAULT_ENABLED : ResourcePackActivationType.NORMAL);
org.quiltmc.loader.api.ModContainer quiltContainer = org.quiltmc.loader.api.QuiltLoader.getModContainer(container.getMetadata().getId()).get();
return org.quiltmc.qsl.resource.loader.impl.ResourceLoaderImpl.registerBuiltinPack(
id,
subPath,
quiltContainer,
enabledByDefault ? org.quiltmc.qsl.resource.loader.api.PackActivationType.DEFAULT_ENABLED : org.quiltmc.qsl.resource.loader.api.PackActivationType.NORMAL,
org.quiltmc.qsl.resource.loader.impl.ResourceLoaderImpl.getBuiltinPackDisplayNameFromId(id)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
* Copyright 2022 The Quilt Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +19,10 @@

/**
* Represents the resource pack activation type.
*
* @deprecated see {@link org.quiltmc.qsl.resource.loader.api.PackActivationType PackActivationType}
*/
@Deprecated
public enum ResourcePackActivationType {
/**
* Normal activation. The user has full control over the activation of the resource pack.
@@ -41,4 +45,12 @@ public enum ResourcePackActivationType {
public boolean isEnabledByDefault() {
return this == DEFAULT_ENABLED || this == ALWAYS_ENABLED;
}

public org.quiltmc.qsl.resource.loader.api.PackActivationType toQuilt() {
return switch (this) {
case NORMAL -> org.quiltmc.qsl.resource.loader.api.PackActivationType.NORMAL;
case DEFAULT_ENABLED -> org.quiltmc.qsl.resource.loader.api.PackActivationType.DEFAULT_ENABLED;
case ALWAYS_ENABLED -> org.quiltmc.qsl.resource.loader.api.PackActivationType.ALWAYS_ENABLED;
};
}
}
Original file line number Diff line number Diff line change
@@ -22,7 +22,10 @@
* This class contains default keys for various Minecraft resource reload listeners.
*
* @see IdentifiableResourceReloadListener
*
* @deprecated see {@link org.quiltmc.qsl.resource.loader.api.reloader.ResourceReloaderKeys ResourceReloaderKeys}
*/
@Deprecated
public final class ResourceReloadListenerKeys {
// client
public static final Identifier SOUNDS = Identifier.ofVanilla("sounds");
Original file line number Diff line number Diff line change
@@ -42,7 +42,10 @@
* {@link IdentifiableResourceReloadListener}.
*
* @param <T> The data object.
*
* @deprecated see {@link org.quiltmc.qsl.resource.loader.api.reloader.SimpleResourceReloader SimpleResourceReloader}
*/
@Deprecated
public interface SimpleResourceReloadListener<T> extends IdentifiableResourceReloadListener {
@Override
default CompletableFuture<Void> reload(ResourceReloader.Synchronizer helper, ResourceManager manager, Profiler loadProfiler, Profiler applyProfiler, Executor loadExecutor, Executor applyExecutor) {
Original file line number Diff line number Diff line change
@@ -21,6 +21,9 @@
/**
* A simplified version of the "resource reload listener" interface, hiding the
* peculiarities of the API and ensuring all data is loaded on the main thread.
*
* @deprecated see {@link org.quiltmc.qsl.resource.loader.api.reloader.SimpleSynchronousResourceReloader SimpleSynchronousResourceReloader}
*/
@Deprecated
public interface SimpleSynchronousResourceReloadListener extends IdentifiableResourceReloadListener, SynchronousResourceReloader {
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -16,296 +16,39 @@

package net.fabricmc.fabric.impl.resource.loader;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;

import com.google.common.collect.Lists;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.quiltmc.qsl.resource.loader.api.ResourceLoader;

import net.minecraft.recipe.RecipeManager;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.resource.OverlayResourcePack;
import net.minecraft.resource.ResourcePack;
import net.minecraft.resource.ResourcePackInfo;
import net.minecraft.resource.ResourcePackPosition;
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourceReloader;
import net.minecraft.resource.ResourceType;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.Pair;

import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.loader.api.ModContainer;

public class ResourceManagerHelperImpl implements ResourceManagerHelper {
private static final Map<ResourceType, ResourceManagerHelperImpl> registryMap = new HashMap<>();
private static final Set<Pair<Text, ModNioResourcePack>> builtinResourcePacks = new HashSet<>();
private static final Logger LOGGER = LoggerFactory.getLogger(ResourceManagerHelperImpl.class);

private final Set<Identifier> addedListenerIds = new HashSet<>();
private final Set<ListenerFactory> listenerFactories = new LinkedHashSet<>();
private final Set<IdentifiableResourceReloadListener> addedListeners = new LinkedHashSet<>();
private final ResourceType type;
private final ResourceLoader quiltLoader;

private ResourceManagerHelperImpl(ResourceType type) {
this.type = type;
this.quiltLoader = ResourceLoader.get(type);
}

public static ResourceManagerHelperImpl get(ResourceType type) {
return registryMap.computeIfAbsent(type, ResourceManagerHelperImpl::new);
}

/**
* Registers a built-in resource pack. Internal implementation.
*
* @param id the identifier of the resource pack
* @param subPath the sub path in the mod resources
* @param container the mod container
* @param displayName the display name of the resource pack
* @param activationType the activation type of the resource pack
* @return {@code true} if successfully registered the resource pack, else {@code false}
* @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, Text, ResourcePackActivationType)
* @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, ResourcePackActivationType)
*/
public static boolean registerBuiltinResourcePack(Identifier id, String subPath, ModContainer container, Text displayName, ResourcePackActivationType activationType) {
// Assuming the mod has multiple paths, we simply "hope" that the file separator is *not* different across them
List<Path> paths = container.getRootPaths();
String separator = paths.getFirst().getFileSystem().getSeparator();
subPath = subPath.replace("/", separator);
ModNioResourcePack resourcePack = ModNioResourcePack.create(id.toString(), container, subPath, ResourceType.CLIENT_RESOURCES, activationType, false);
ModNioResourcePack dataPack = ModNioResourcePack.create(id.toString(), container, subPath, ResourceType.SERVER_DATA, activationType, false);
if (resourcePack == null && dataPack == null) return false;

if (resourcePack != null) {
builtinResourcePacks.add(new Pair<>(displayName, resourcePack));
}

if (dataPack != null) {
builtinResourcePacks.add(new Pair<>(displayName, dataPack));
}

return true;
}

/**
* Registers a built-in resource pack. Internal implementation.
*
* @param id the identifier of the resource pack
* @param subPath the sub path in the mod resources
* @param container the mod container
* @param activationType the activation type of the resource pack
* @return {@code true} if successfully registered the resource pack, else {@code false}
* @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, ResourcePackActivationType)
* @see ResourceManagerHelper#registerBuiltinResourcePack(Identifier, ModContainer, Text, ResourcePackActivationType)
*/
public static boolean registerBuiltinResourcePack(Identifier id, String subPath, ModContainer container, ResourcePackActivationType activationType) {
return registerBuiltinResourcePack(id, subPath, container, Text.literal(id.getNamespace() + "/" + id.getPath()), activationType);
}

public static void registerBuiltinResourcePacks(ResourceType resourceType, Consumer<ResourcePackProfile> consumer) {
// Loop through each registered built-in resource packs and add them if valid.
for (Pair<Text, ModNioResourcePack> entry : builtinResourcePacks) {
ModNioResourcePack pack = entry.getRight();

// Add the built-in pack only if namespaces for the specified resource type are present.
if (!pack.getNamespaces(resourceType).isEmpty()) {
// Make the resource pack profile for built-in pack, should never be always enabled.
ResourcePackInfo info = new ResourcePackInfo(
entry.getRight().getId(),
entry.getLeft(),
new BuiltinModResourcePackSource(pack.getFabricModMetadata().getName()),
entry.getRight().getKnownPackInfo()
);
ResourcePackPosition info2 = new ResourcePackPosition(
pack.getActivationType() == ResourcePackActivationType.ALWAYS_ENABLED,
ResourcePackProfile.InsertionPosition.TOP,
false
);

ResourcePackProfile profile = ResourcePackProfile.create(info, new ResourcePackProfile.PackFactory() {
@Override
public ResourcePack open(ResourcePackInfo var1) {
return entry.getRight();
}

@Override
public ResourcePack openWithOverlays(ResourcePackInfo var1, ResourcePackProfile.Metadata metadata) {
ModNioResourcePack pack = entry.getRight();

if (metadata.overlays().isEmpty()) {
return pack;
}

List<ResourcePack> overlays = new ArrayList<>(metadata.overlays().size());

for (String overlay : metadata.overlays()) {
overlays.add(pack.createOverlay(overlay));
}

return new OverlayResourcePack(pack, overlays);
}
}, resourceType, info2);
consumer.accept(profile);
}
}
}

public static List<ResourceReloader> sort(ResourceType type, List<ResourceReloader> listeners) {
if (type == null) {
return listeners;
}

ResourceManagerHelperImpl instance = get(type);

if (instance != null) {
List<ResourceReloader> mutable = new ArrayList<>(listeners);
instance.sort(mutable);
return Collections.unmodifiableList(mutable);
}

return listeners;
}

protected void sort(List<ResourceReloader> listeners) {
listeners.removeAll(addedListeners);

// General rules:
// - We *do not* touch the ordering of vanilla listeners. Ever.
// While dependency values are provided where possible, we cannot
// trust them 100%. Only code doesn't lie.
// - We addReloadListener all custom listeners after vanilla listeners. Same reasons.

final RegistryWrapper.WrapperLookup wrapperLookup = getWrapperLookup(listeners);
List<IdentifiableResourceReloadListener> listenersToAdd = Lists.newArrayList();

for (ListenerFactory addedListener : listenerFactories) {
listenersToAdd.add(addedListener.get(wrapperLookup));
}

addedListeners.clear();
addedListeners.addAll(listenersToAdd);

Set<Identifier> resolvedIds = new HashSet<>();

for (ResourceReloader listener : listeners) {
if (listener instanceof IdentifiableResourceReloadListener) {
resolvedIds.add(((IdentifiableResourceReloadListener) listener).getFabricId());
}
}

int lastSize = -1;

while (listeners.size() != lastSize) {
lastSize = listeners.size();

Iterator<IdentifiableResourceReloadListener> it = listenersToAdd.iterator();

while (it.hasNext()) {
IdentifiableResourceReloadListener listener = it.next();

if (resolvedIds.containsAll(listener.getFabricDependencies())) {
resolvedIds.add(listener.getFabricId());
listeners.add(listener);
it.remove();
}
}
}

for (IdentifiableResourceReloadListener listener : listenersToAdd) {
LOGGER.warn("Could not resolve dependencies for listener: " + listener.getFabricId() + "!");
}
}

// A bit of a hack to get the registry, but it works.
@Nullable
private RegistryWrapper.WrapperLookup getWrapperLookup(List<ResourceReloader> listeners) {
if (type == ResourceType.CLIENT_RESOURCES) {
// We don't need the registry for client resources.
return null;
}

for (ResourceReloader resourceReloader : listeners) {
if (resourceReloader instanceof RecipeManager recipeManager) {
return recipeManager.registryLookup;
}
}

throw new IllegalStateException("No RecipeManager found in listeners!");
}

@Override
public void registerReloadListener(IdentifiableResourceReloadListener listener) {
registerReloadListener(new SimpleResourceReloaderFactory(listener));
this.quiltLoader.registerReloader(listener);
}

@Override
public void registerReloadListener(Identifier identifier, Function<RegistryWrapper.WrapperLookup, IdentifiableResourceReloadListener> listenerFactory) {
if (type == ResourceType.CLIENT_RESOURCES) {
throw new IllegalArgumentException("Cannot register a registry listener for the client resource type!");
}

registerReloadListener(new RegistryResourceReloaderFactory(identifier, listenerFactory));
}

private void registerReloadListener(ListenerFactory factory) {
if (!addedListenerIds.add(factory.id())) {
LOGGER.warn("Tried to register resource reload listener " + factory.id() + " twice!");
return;
}

if (!listenerFactories.add(factory)) {
throw new RuntimeException("Listener with previously unknown ID " + factory.id() + " already in listener set!");
}
}

private sealed interface ListenerFactory permits SimpleResourceReloaderFactory, RegistryResourceReloaderFactory {
Identifier id();

IdentifiableResourceReloadListener get(RegistryWrapper.WrapperLookup registry);
}

private record SimpleResourceReloaderFactory(IdentifiableResourceReloadListener listener) implements ListenerFactory {
@Override
public Identifier id() {
return listener.getFabricId();
}

@Override
public IdentifiableResourceReloadListener get(RegistryWrapper.WrapperLookup registry) {
return listener;
}
}

private record RegistryResourceReloaderFactory(Identifier id, Function<RegistryWrapper.WrapperLookup, IdentifiableResourceReloadListener> listenerFactory) implements ListenerFactory {
private RegistryResourceReloaderFactory {
Objects.requireNonNull(listenerFactory);
}

@Override
public IdentifiableResourceReloadListener get(RegistryWrapper.WrapperLookup registry) {
final IdentifiableResourceReloadListener listener = listenerFactory.apply(registry);

if (!id.equals(listener.getFabricId())) {
throw new IllegalStateException("Listener factory for " + id + " created a listener with ID " + listener.getFabricId());
}

return listener;
}
this.quiltLoader.registerReloader(identifier, listenerFactory::apply);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package net.fabricmc.fabric.mixin.resource.loader;

import java.util.List;

import com.llamalad7.mixinextras.sugar.Local;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.quiltmc.qsl.base.api.phase.PhaseData;
import org.quiltmc.qsl.resource.loader.impl.ResourceLoaderImpl;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Coerce;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.registry.RegistryWrapper;
import net.minecraft.resource.ResourceReloader;
import net.minecraft.util.Identifier;

import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;

@Mixin(ResourceLoaderImpl.class)
public class ResourceLoaderImplMixin {
@Inject(
method = "sort(Ljava/util/List;Lnet/minecraft/registry/RegistryWrapper$WrapperLookup;)V",
at = @At(
value = "INVOKE",
target = "Lit/unimi/dsi/fastutil/objects/Object2ObjectOpenHashMap;values()Lit/unimi/dsi/fastutil/objects/ObjectCollection;",
ordinal = 0
)
)
public void addFabricOrdering(List<ResourceReloader> reloaders, RegistryWrapper.WrapperLookup provider, CallbackInfo ci, @Coerce @Local Object2ObjectOpenHashMap<Identifier, Object> runtimePhases) {
for (ResourceReloader reloader : reloaders) {
if (reloader instanceof IdentifiableResourceReloadListener fabric) {
var second = runtimePhases.get(fabric.getQuiltId());
if (second != null) {
for (Identifier fabricDependency : fabric.getFabricDependencies()) {
var first = runtimePhases.get(fabricDependency);
if (first != null) {
PhaseData.link((PhaseData) first, (PhaseData) second);
}
}
}
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -16,12 +16,8 @@

package net.fabricmc.fabric.mixin.resource.loader;

import java.util.Set;
import java.util.function.Predicate;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@@ -31,7 +27,6 @@
import net.minecraft.resource.ResourcePackProfile;
import net.minecraft.resource.ResourcePackSource;

import net.fabricmc.fabric.impl.resource.loader.FabricResourcePackProfile;
import net.fabricmc.fabric.impl.resource.loader.ResourcePackSourceTracker;

/**
@@ -42,32 +37,12 @@
* @see ResourcePackSourceTracker
*/
@Mixin(ResourcePackProfile.class)
abstract class ResourcePackProfileMixin implements FabricResourcePackProfile {
@Unique
private static final Predicate<Set<String>> DEFAULT_PARENT_PREDICATE = parents -> true;
@Unique
private Predicate<Set<String>> parentsPredicate = DEFAULT_PARENT_PREDICATE;

abstract class ResourcePackProfileMixin {
@Shadow
public abstract ResourcePackInfo getInfo();

@Inject(method = "createResourcePack", at = @At("RETURN"))
private void onCreateResourcePack(CallbackInfoReturnable<ResourcePack> info) {
ResourcePackSourceTracker.setSource(info.getReturnValue(), getInfo().source());
}

@Override
public boolean fabric_isHidden() {
return parentsPredicate != DEFAULT_PARENT_PREDICATE;
}

@Override
public boolean fabric_parentsEnabled(Set<String> enabled) {
return parentsPredicate.test(enabled);
}

@Override
public void fabric_setParentsPredicate(Predicate<Set<String>> predicate) {
this.parentsPredicate = predicate;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -3,22 +3,10 @@
"package": "net.fabricmc.fabric.mixin.resource.loader",
"compatibilityLevel": "JAVA_17",
"mixins": [
"DatapackCommandMixin",
"KeyedResourceReloadListenerMixin",
"LifecycledResourceManagerImplMixin",
"MinecraftServerMixin",
"ResourceLoaderImplMixin",
"ResourceMixin",
"ResourcePackManagerMixin",
"ResourcePackProfileMixin",
"SelectKnownPacksC2SPacketMixin",
"ServerConfigurationNetworkHandlerMixin",
"ServerPropertiesHandlerMixin",
"SimpleResourceReloadMixin",
"SynchronizeRegistriesTaskMixin",
"TestServerMixin"
],
"server": [
"server.LanguageMixin"
"ResourcePackProfileMixin"
],
"injectors": {
"defaultRequire": 1
Loading

0 comments on commit 1ea68f5

Please sign in to comment.