Fix jGui resources in 1.16 dev env
This commit is contained in:
@@ -233,15 +233,17 @@ public class ReplayMod implements
|
|||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final DirectoryResourcePack jGuiResourcePack;
|
||||||
static { // Note: even preInit is too late and we'd have to issue another resource reload
|
static { // Note: even preInit is too late and we'd have to issue another resource reload
|
||||||
initJGuiResourcePack();
|
jGuiResourcePack = initJGuiResourcePack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initJGuiResourcePack() {
|
private static DirectoryResourcePack initJGuiResourcePack() {
|
||||||
File folder = new File("../jGui/src/main/resources");
|
File folder = new File("../jGui/src/main/resources");
|
||||||
if (!folder.exists()) {
|
if (!folder.exists()) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
//noinspection UnnecessaryLocalVariable
|
||||||
DirectoryResourcePack jGuiResourcePack = new DirectoryResourcePack(folder) {
|
DirectoryResourcePack jGuiResourcePack = new DirectoryResourcePack(folder) {
|
||||||
@Override
|
@Override
|
||||||
protected InputStream openFile(String resourceName) throws IOException {
|
protected InputStream openFile(String resourceName) throws IOException {
|
||||||
@@ -261,22 +263,13 @@ public class ReplayMod implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//#if MC>=11600
|
|
||||||
//$$ // TODO
|
//#if MC<=11202
|
||||||
//#else
|
|
||||||
//#if MC>=11400
|
|
||||||
mc.getResourcePackManager().registerProvider(new ResourcePackProvider() {
|
|
||||||
@Override
|
|
||||||
public <T extends ResourcePackProfile> void register(Map<String, T> map, ResourcePackProfile.Factory<T> factory) {
|
|
||||||
map.put("jgui", ResourcePackProfile.of("jgui", true, () -> jGuiResourcePack, factory, ResourcePackProfile.InsertionPosition.BOTTOM));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//#else
|
|
||||||
//$$ @SuppressWarnings("unchecked")
|
//$$ @SuppressWarnings("unchecked")
|
||||||
//$$ List<IResourcePack> defaultResourcePacks = ((MinecraftAccessor) mc).getDefaultResourcePacks();
|
//$$ List<IResourcePack> defaultResourcePacks = ((MinecraftAccessor) mc).getDefaultResourcePacks();
|
||||||
//$$ defaultResourcePacks.add(jGuiResourcePack);
|
//$$ defaultResourcePacks.add(jGuiResourcePack);
|
||||||
//#endif
|
//#endif
|
||||||
//#endif
|
|
||||||
//#if MC<=10710
|
//#if MC<=10710
|
||||||
//$$ FolderResourcePack mainResourcePack = new FolderResourcePack(new File("../src/main/resources")) {
|
//$$ FolderResourcePack mainResourcePack = new FolderResourcePack(new File("../src/main/resources")) {
|
||||||
//$$ @Override
|
//$$ @Override
|
||||||
@@ -293,6 +286,8 @@ public class ReplayMod implements
|
|||||||
//$$ };
|
//$$ };
|
||||||
//$$ defaultResourcePacks.add(mainResourcePack);
|
//$$ defaultResourcePacks.add(mainResourcePack);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
return jGuiResourcePack;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#if FABRIC>=1
|
//#if FABRIC>=1
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ public class MixinModResourcePackUtil {
|
|||||||
if (pack instanceof ModResourcePack && ((ModResourcePack) pack).getFabricModMetadata().getId().equals(ReplayMod.MOD_ID)) {
|
if (pack instanceof ModResourcePack && ((ModResourcePack) pack).getFabricModMetadata().getId().equals(ReplayMod.MOD_ID)) {
|
||||||
ModContainer container = FabricLoader.getInstance().getModContainer(ReplayMod.MOD_ID).orElseThrow(IllegalAccessError::new);
|
ModContainer container = FabricLoader.getInstance().getModContainer(ReplayMod.MOD_ID).orElseThrow(IllegalAccessError::new);
|
||||||
packList.add(i, new LangResourcePack(container.getRootPath()));
|
packList.add(i, new LangResourcePack(container.getRootPath()));
|
||||||
|
if (ReplayMod.jGuiResourcePack != null) {
|
||||||
|
packList.add(i, ReplayMod.jGuiResourcePack);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user