rc1, work around a known bug with fabulous shaders
This commit is contained in:
parent
61306eef50
commit
b985879809
@ -2,16 +2,15 @@
|
|||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/versions.html
|
# check these on https://fabricmc.net/versions.html
|
||||||
minecraft_version=1.18-pre4
|
minecraft_version=1.18-rc1
|
||||||
yarn_mappings=build.9
|
yarn_mappings=build.1
|
||||||
loader_version=0.12.5
|
loader_version=0.12.5
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=2.8.3
|
|
||||||
maven_group=io.gitlab.jfronny
|
maven_group=io.gitlab.jfronny
|
||||||
archives_base_name=respackopts
|
archives_base_name=respackopts
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.42.7+1.18
|
fabric_version=0.43.1+1.18
|
||||||
jfapi_version=2.1.4-412595557
|
jfapi_version=2.1.3-416552327
|
||||||
|
|
||||||
modrinth_id=TiF5QWZY
|
modrinth_id=TiF5QWZY
|
||||||
modrinth_required_dependencies=3CD6YUw1
|
modrinth_required_dependencies=3CD6YUw1
|
||||||
|
@ -2,10 +2,10 @@ package io.gitlab.jfronny.respackopts.filters;
|
|||||||
|
|
||||||
import io.gitlab.jfronny.libjf.ResourcePath;
|
import io.gitlab.jfronny.libjf.ResourcePath;
|
||||||
import io.gitlab.jfronny.libjf.data.manipulation.api.UserResourceEvents;
|
import io.gitlab.jfronny.libjf.data.manipulation.api.UserResourceEvents;
|
||||||
import io.gitlab.jfronny.respackopts.util.MetaCache;
|
|
||||||
import io.gitlab.jfronny.respackopts.Respackopts;
|
import io.gitlab.jfronny.respackopts.Respackopts;
|
||||||
import io.gitlab.jfronny.respackopts.model.DirRpo;
|
import io.gitlab.jfronny.respackopts.model.DirRpo;
|
||||||
import io.gitlab.jfronny.respackopts.model.enums.PackCapability;
|
import io.gitlab.jfronny.respackopts.model.enums.PackCapability;
|
||||||
|
import io.gitlab.jfronny.respackopts.util.MetaCache;
|
||||||
import io.gitlab.jfronny.respackopts.util.RpoFormatException;
|
import io.gitlab.jfronny.respackopts.util.RpoFormatException;
|
||||||
import net.minecraft.resource.ResourcePack;
|
import net.minecraft.resource.ResourcePack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@ -19,7 +19,7 @@ public class DirFilterEventImpl {
|
|||||||
public static void init() {
|
public static void init() {
|
||||||
UserResourceEvents.OPEN.register((type, id, previous, pack) -> {
|
UserResourceEvents.OPEN.register((type, id, previous, pack) -> {
|
||||||
if (!MetaCache.hasCapability(pack, PackCapability.DirFilter))
|
if (!MetaCache.hasCapability(pack, PackCapability.DirFilter))
|
||||||
return previous;
|
return previous.get();
|
||||||
String path = new ResourcePath(type, id).getName();
|
String path = new ResourcePath(type, id).getName();
|
||||||
DirRpo rpo = findDirRpo(pack, path);
|
DirRpo rpo = findDirRpo(pack, path);
|
||||||
if (rpo != null && dirHidden(rpo, MetaCache.getId(pack))) {
|
if (rpo != null && dirHidden(rpo, MetaCache.getId(pack))) {
|
||||||
@ -28,16 +28,17 @@ public class DirFilterEventImpl {
|
|||||||
ResourcePath rp = new ResourcePath(path);
|
ResourcePath rp = new ResourcePath(path);
|
||||||
return pack.open(rp.getType(), rp.getId());
|
return pack.open(rp.getType(), rp.getId());
|
||||||
}
|
}
|
||||||
return previous;
|
return previous.get();
|
||||||
});
|
});
|
||||||
UserResourceEvents.FIND_RESOURCE.register((type, namespace, prefix, maxDepth, pathFilter, previous, pack) -> {
|
UserResourceEvents.FIND_RESOURCE.register((type, namespace, prefix, maxDepth, pathFilter, previous, pack) -> {
|
||||||
// Warning: the Identifiers here DON'T CONTAIN THE TYPE!
|
// Warning: the Identifiers here DON'T CONTAIN THE TYPE!
|
||||||
// Therefore, it needs to be added when calling a method that generates a ResourcePath!
|
// Therefore, it needs to be added when calling a method that generates a ResourcePath!
|
||||||
|
Collection<Identifier> prevVals = previous.get();
|
||||||
if (!MetaCache.hasCapability(pack, PackCapability.DirFilter))
|
if (!MetaCache.hasCapability(pack, PackCapability.DirFilter))
|
||||||
return previous;
|
return prevVals;
|
||||||
Collection<Identifier> nextRes = new LinkedHashSet<>(previous);
|
Collection<Identifier> nextRes = new LinkedHashSet<>(prevVals);
|
||||||
boolean dirFilterAdditive = MetaCache.hasCapability(pack, PackCapability.DirFilterAdditive);
|
boolean dirFilterAdditive = MetaCache.hasCapability(pack, PackCapability.DirFilterAdditive);
|
||||||
for (Identifier identifier : previous) {
|
for (Identifier identifier : prevVals) {
|
||||||
String path = type.getDirectory() + "/" + identifier.getNamespace() + "/" + identifier.getPath();
|
String path = type.getDirectory() + "/" + identifier.getNamespace() + "/" + identifier.getPath();
|
||||||
DirRpo rpo = findDirRpo(pack, path);
|
DirRpo rpo = findDirRpo(pack, path);
|
||||||
if (rpo != null) {
|
if (rpo != null) {
|
||||||
@ -66,7 +67,7 @@ public class DirFilterEventImpl {
|
|||||||
});
|
});
|
||||||
UserResourceEvents.CONTAINS.register((type, id, previous, pack) -> {
|
UserResourceEvents.CONTAINS.register((type, id, previous, pack) -> {
|
||||||
if (!MetaCache.hasCapability(pack, PackCapability.DirFilter))
|
if (!MetaCache.hasCapability(pack, PackCapability.DirFilter))
|
||||||
return previous;
|
return previous.get();
|
||||||
String path = new ResourcePath(type, id).getName();
|
String path = new ResourcePath(type, id).getName();
|
||||||
DirRpo rpo = findDirRpo(pack, path);
|
DirRpo rpo = findDirRpo(pack, path);
|
||||||
if (rpo != null && dirHidden(rpo, MetaCache.getId(pack))) {
|
if (rpo != null && dirHidden(rpo, MetaCache.getId(pack))) {
|
||||||
@ -76,7 +77,7 @@ public class DirFilterEventImpl {
|
|||||||
ResourcePath rp = new ResourcePath(path);
|
ResourcePath rp = new ResourcePath(path);
|
||||||
return pack.contains(rp.getType(), rp.getId());
|
return pack.contains(rp.getType(), rp.getId());
|
||||||
}
|
}
|
||||||
return previous;
|
return previous.get();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import net.minecraft.resource.AbstractFileResourcePack;
|
|||||||
import net.minecraft.resource.ResourcePack;
|
import net.minecraft.resource.ResourcePack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -28,32 +29,33 @@ public class FileFilterEventImpl {
|
|||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
UserResourceEvents.OPEN.register((type, id, previous, pack) -> {
|
UserResourceEvents.OPEN.register((type, id, previous, pack) -> {
|
||||||
if (skip(pack)) return previous;
|
if (skip(pack)) return previous.get();
|
||||||
String name = new ResourcePath(type, id).getName();
|
String name = new ResourcePath(type, id).getName();
|
||||||
if (pack.contains(type, id)) {
|
if (pack.contains(type, id)) {
|
||||||
return containsFileWasFallback()
|
return containsFileWasFallback()
|
||||||
? FileFallbackProvider.getReplacement(pack, name)
|
? FileFallbackProvider.getReplacement(pack, name)
|
||||||
: FileExpansionProvider.replace(previous, pack, name);
|
: FileExpansionProvider.replace(previous.get(), pack, name);
|
||||||
}
|
}
|
||||||
else return null;
|
else return null;
|
||||||
});
|
});
|
||||||
UserResourceEvents.FIND_RESOURCE.register((type, namespace, prefix, maxDepth, pathFilter, previous, pack) -> {
|
UserResourceEvents.FIND_RESOURCE.register((type, namespace, prefix, maxDepth, pathFilter, previous, pack) -> {
|
||||||
// Warning: the Identifiers here DON'T CONTAIN THE TYPE!
|
// Warning: the Identifiers here DON'T CONTAIN THE TYPE!
|
||||||
// Therefore, it needs to be added when calling a method that generates a ResourcePath!
|
// Therefore, it needs to be added when calling a method that generates a ResourcePath!
|
||||||
if (skip(pack)) return previous;
|
Collection<Identifier> prevVals = previous.get();
|
||||||
previous.removeIf(s -> {
|
if (skip(pack)) return prevVals;
|
||||||
|
prevVals.removeIf(s -> {
|
||||||
String fileName = type.getDirectory() + "/" + s.getNamespace() + "/" + s.getPath();
|
String fileName = type.getDirectory() + "/" + s.getNamespace() + "/" + s.getPath();
|
||||||
return FileExclusionProvider.fileHidden(pack, fileName) && !FileFallbackProvider.fileHasFallback(pack, fileName);
|
return FileExclusionProvider.fileHidden(pack, fileName) && !FileFallbackProvider.fileHasFallback(pack, fileName);
|
||||||
});
|
});
|
||||||
// Completion of the path is handled separately here
|
// Completion of the path is handled separately here
|
||||||
FileFallbackProvider.addFallbackResources(pack, previous, namespace, type);
|
FileFallbackProvider.addFallbackResources(pack, prevVals, namespace, type);
|
||||||
return previous;
|
return prevVals;
|
||||||
});
|
});
|
||||||
UserResourceEvents.CONTAINS.register((type, id, previous, pack) -> {
|
UserResourceEvents.CONTAINS.register((type, id, previous, pack) -> {
|
||||||
if (skip(pack)) return previous;
|
if (skip(pack)) return previous.get();
|
||||||
containsFileWasFallback(false);
|
containsFileWasFallback(false);
|
||||||
String name = new ResourcePath(type, id).getName();
|
String name = new ResourcePath(type, id).getName();
|
||||||
if (previous) {
|
if (previous.get()) {
|
||||||
if (FileExclusionProvider.fileHidden(pack, name)) {
|
if (FileExclusionProvider.fileHidden(pack, name)) {
|
||||||
if (FileFallbackProvider.fileHasFallback(pack, name)) {
|
if (FileFallbackProvider.fileHasFallback(pack, name)) {
|
||||||
containsFileWasFallback(true);
|
containsFileWasFallback(true);
|
||||||
|
@ -8,8 +8,9 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
|||||||
|
|
||||||
@Mixin(GLImportProcessor.class)
|
@Mixin(GLImportProcessor.class)
|
||||||
public class GLImportProcessorMixin {
|
public class GLImportProcessorMixin {
|
||||||
|
private static final String respackopts$prefix = "\n//include " + Respackopts.RPO_SHADER_ID;
|
||||||
@ModifyArg(method = "readSource(Ljava/lang/String;)Ljava/util/List;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/GLImportProcessor;parseImports(Ljava/lang/String;Lnet/minecraft/client/gl/GLImportProcessor$Context;Ljava/lang/String;)Ljava/util/List;"), index = 0)
|
@ModifyArg(method = "readSource(Ljava/lang/String;)Ljava/util/List;", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/GLImportProcessor;parseImports(Ljava/lang/String;Lnet/minecraft/client/gl/GLImportProcessor$Context;Ljava/lang/String;)Ljava/util/List;"), index = 0)
|
||||||
private String modify(String value) {
|
private String modify(String value) {
|
||||||
return value.replace("\n//include " + Respackopts.RPO_SHADER_ID, "\n" + Respackopts.getShaderImportSource());
|
return value.replace(respackopts$prefix, "\n" + Respackopts.getShaderImportSource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import io.gitlab.jfronny.respackopts.model.PackMeta;
|
|||||||
import net.minecraft.resource.*;
|
import net.minecraft.resource.*;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
@ -13,15 +14,19 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Mixin(ResourcePackManager.class)
|
@Mixin(ResourcePackManager.class)
|
||||||
public class ResourcePackManagerMixin {
|
public class ResourcePackManagerMixin {
|
||||||
@Shadow private Map<String, ResourcePackProfile> profiles;
|
@Shadow private Map<String, ResourcePackProfile> profiles;
|
||||||
|
@Unique private final Set<String> packIds = new HashSet<>();
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "scanPacks()V")
|
@Inject(at = @At("TAIL"), method = "scanPacks()V")
|
||||||
private void scanPacks(CallbackInfo info) {
|
private void scanPacks(CallbackInfo info) {
|
||||||
MetaCache.clear();
|
Set<String> toRemove = new HashSet<>(packIds);
|
||||||
|
packIds.clear();
|
||||||
profiles.forEach((s, v) -> {
|
profiles.forEach((s, v) -> {
|
||||||
ResourcePack rpi = v.createResourcePack();
|
ResourcePack rpi = v.createResourcePack();
|
||||||
ResourceType packConfType = null;
|
ResourceType packConfType = null;
|
||||||
@ -49,11 +54,16 @@ public class ResourcePackManagerMixin {
|
|||||||
else {
|
else {
|
||||||
MetaCache.addFromScan(displayName, packName, conf, Respackopts.FALLBACK_CONF_DIR.resolve(conf.id + ".json"));
|
MetaCache.addFromScan(displayName, packName, conf, Respackopts.FALLBACK_CONF_DIR.resolve(conf.id + ".json"));
|
||||||
}
|
}
|
||||||
|
packIds.add(conf.id);
|
||||||
|
toRemove.remove(conf.id);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Respackopts.LOGGER.error("Could not initialize pack meta for " + s, e);
|
Respackopts.LOGGER.error("Could not initialize pack meta for " + s, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
for (String s : toRemove) {
|
||||||
|
MetaCache.remove(s);
|
||||||
|
}
|
||||||
MetaCache.save();
|
MetaCache.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,14 +28,14 @@ public class MetaCache {
|
|||||||
private static final Map<String, String> PACK_NAME_LOOKUP = new HashMap<>(); // pack name -> pack id
|
private static final Map<String, String> PACK_NAME_LOOKUP = new HashMap<>(); // pack name -> pack id
|
||||||
public static final Map<String, Map<String, DirRpo>> DIR_RPOS = new HashMap<>(); // pack id -> .rpo path -> parsed .rpo
|
public static final Map<String, Map<String, DirRpo>> DIR_RPOS = new HashMap<>(); // pack id -> .rpo path -> parsed .rpo
|
||||||
public static final Map<String, Map<String, FileRpo>> FILE_RPOS = new HashMap<>(); // pack id -> .rpo path -> parsed .rpo
|
public static final Map<String, Map<String, FileRpo>> FILE_RPOS = new HashMap<>(); // pack id -> .rpo path -> parsed .rpo
|
||||||
public static void clear() {
|
public static void remove(String packId) {
|
||||||
CONFIG_BRANCH.clear();
|
CONFIG_BRANCH.remove(packId);
|
||||||
PACK_METAS.clear();
|
PACK_METAS.remove(packId);
|
||||||
DATA_LOCATIONS.clear();
|
DATA_LOCATIONS.remove(packId);
|
||||||
DISPLAY_NAME_LOOKUP.clear();
|
DISPLAY_NAME_LOOKUP.remove(packId);
|
||||||
PACK_NAME_LOOKUP.clear();
|
//PACK_NAME_LOOKUP
|
||||||
DIR_RPOS.clear();
|
DIR_RPOS.remove(packId);
|
||||||
FILE_RPOS.clear();
|
FILE_RPOS.remove(packId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addFromScan(String displayName, String packName, PackMeta meta, Path dataLocation) {
|
public static void addFromScan(String displayName, String packName, PackMeta meta, Path dataLocation) {
|
||||||
@ -44,6 +44,7 @@ public class MetaCache {
|
|||||||
}
|
}
|
||||||
meta.conf.setVersion(meta.version);
|
meta.conf.setVersion(meta.version);
|
||||||
if (meta.version < 5) meta.capabilities.add(PackCapability.DirFilter);
|
if (meta.version < 5) meta.capabilities.add(PackCapability.DirFilter);
|
||||||
|
remove(meta.id);
|
||||||
if (CONFIG_BRANCH.containsKey(meta.id))
|
if (CONFIG_BRANCH.containsKey(meta.id))
|
||||||
CONFIG_BRANCH.get(meta.id).sync(meta.conf, ConfigSyncMode.RESPACK_LOAD);
|
CONFIG_BRANCH.get(meta.id).sync(meta.conf, ConfigSyncMode.RESPACK_LOAD);
|
||||||
else
|
else
|
||||||
@ -128,6 +129,9 @@ public class MetaCache {
|
|||||||
public static boolean hasCapability(ResourcePack pack, PackCapability capability) {
|
public static boolean hasCapability(ResourcePack pack, PackCapability capability) {
|
||||||
String id = getId(pack);
|
String id = getId(pack);
|
||||||
if (id == null) return false;
|
if (id == null) return false;
|
||||||
|
if (!PACK_METAS.containsKey(id)) {
|
||||||
|
throw new NullPointerException("Could not get pack \"" + id + "\" (available: " + String.join(", ", PACK_METAS.keySet()) + ")");
|
||||||
|
}
|
||||||
return PACK_METAS.get(id).capabilities.contains(capability);
|
return PACK_METAS.get(id).capabilities.contains(capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user