diff options
author | SHsuperCM <shsupercm@gmail.com> | 2021-08-20 15:48:24 +0300 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2021-08-20 15:48:24 +0300 |
commit | ec00a9307d3eadca3a7407173320f7f941401164 (patch) | |
tree | 3de50a3977a638dd796908d15e3a71852efcb1eb /src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ReloadableResourceManagerImplMixin.java | |
download | CITResewn-ec00a9307d3eadca3a7407173320f7f941401164.tar.gz CITResewn-ec00a9307d3eadca3a7407173320f7f941401164.tar.bz2 CITResewn-ec00a9307d3eadca3a7407173320f7f941401164.zip |
Initial commit
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ReloadableResourceManagerImplMixin.java')
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ReloadableResourceManagerImplMixin.java | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ReloadableResourceManagerImplMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ReloadableResourceManagerImplMixin.java new file mode 100644 index 0000000..01b092b --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ReloadableResourceManagerImplMixin.java @@ -0,0 +1,48 @@ +package shcm.shsupercm.fabric.citresewn.mixin; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.resource.*; +import net.minecraft.util.Identifier; +import net.minecraft.util.Unit; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.function.Predicate; +import java.util.stream.Stream; + +@Mixin(ReloadableResourceManagerImpl.class) +public abstract class ReloadableResourceManagerImplMixin implements ReloadableResourceManager { + @Shadow @Final private ResourceType type; + @Shadow public abstract Stream<ResourcePack> streamResourcePacks(); + + @Shadow public abstract Collection<Identifier> findResources(String startingPath, Predicate<String> pathPredicate); + + @Inject(method = "reload", at = @At("HEAD")) + private void onReload(Executor prepareExecutor, Executor applyExecutor, CompletableFuture<Unit> initialStage, List<ResourcePack> packs, CallbackInfoReturnable<ResourceReload> cir) { + if (this.type != ResourceType.CLIENT_RESOURCES) + return; + + Map<String, ResourcePack> citFiles = new HashMap<>(); + for (ResourcePack pack : packs) { + for (Identifier identifier : pack.findResources(ResourceType.CLIENT_RESOURCES, "minecraft", "citresewn/cit", 5, s -> true)) + citFiles.put(identifier.getPath(), pack); + for (Identifier identifier : pack.findResources(ResourceType.CLIENT_RESOURCES, "minecraft", "mcpatcher/cit", 5, s -> true)) + citFiles.put(identifier.getPath(), pack); + for (Identifier identifier : pack.findResources(ResourceType.CLIENT_RESOURCES, "minecraft", "optifine/cit", 5, s -> true)) + citFiles.put(identifier.getPath(), pack); + } + + for (Map.Entry<String, ResourcePack> citFile : citFiles.entrySet()) { + + } + + new String(); + } +}
\ No newline at end of file |