diff --git a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java b/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java index 400221aff7..ae4999840e 100644 --- a/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java +++ b/src/fmllauncher/java/net/minecraftforge/fml/loading/StringSubstitutor.java @@ -31,8 +31,8 @@ import java.util.Map; public class StringSubstitutor { private static final Map globals = ImmutableMap.of( - "mcVersion", FMLLoader.forgeVersion, - "forgeVersion", FMLLoader.mcVersion + "mcVersion", FMLLoader.mcVersion, + "forgeVersion", FMLLoader.forgeVersion ); public static String replace(final String in, final ModFile file) { @@ -52,7 +52,7 @@ public class StringSubstitutor { return globals.get(parts[1]); } - else if ("file".equals(pfx)) + else if ("file".equals(pfx) && file != null) { return String.valueOf(file.getSubstitutionMap().get().get(parts[1])); } @@ -60,7 +60,4 @@ public class StringSubstitutor } }; } - private static List split(final String in) { - return Arrays.asList(in.split(".")); - } } diff --git a/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java b/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java index a4413b57b6..48357e3758 100644 --- a/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java +++ b/src/main/java/net/minecraftforge/fml/client/gui/GuiModList.java @@ -433,8 +433,8 @@ public class GuiModList extends GuiScreen Pair logoData = selectedMod.getLogoFile().map(logoFile-> { TextureManager tm = mc.getTextureManager(); - ResourcePackInfoClient pack = ResourcePackLoader.getResourcePackInfo(selectedMod.getModId()); - if (pack == null) pack = ResourcePackLoader.getResourcePackInfo("forge"); + ResourcePackInfoClient pack = ResourcePackLoader.getResourcePackInfoForModId(selectedMod.getModId()); + if (pack == null) pack = ResourcePackLoader.getResourcePackInfoForModId("forge"); try { NativeImage logo = null; diff --git a/src/main/java/net/minecraftforge/fml/packs/ModFileResourcePack.java b/src/main/java/net/minecraftforge/fml/packs/ModFileResourcePack.java index 264867b64f..8894e6c371 100644 --- a/src/main/java/net/minecraftforge/fml/packs/ModFileResourcePack.java +++ b/src/main/java/net/minecraftforge/fml/packs/ModFileResourcePack.java @@ -20,6 +20,7 @@ package net.minecraftforge.fml.packs; import net.minecraft.resources.AbstractResourcePack; +import net.minecraft.resources.ResourcePackInfo; import net.minecraft.resources.ResourcePackType; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.loading.moddiscovery.ModFile; @@ -42,6 +43,7 @@ import com.google.common.base.Joiner; public class ModFileResourcePack extends AbstractResourcePack { private final ModFile modFile; + private ResourcePackInfo packInfo; public ModFileResourcePack(final ModFile modFile) { @@ -135,4 +137,12 @@ public class ModFileResourcePack extends AbstractResourcePack { } + + void setPackInfo(final T packInfo) { + this.packInfo = packInfo; + } + + T getPackInfo() { + return (T)this.packInfo; + } } diff --git a/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java b/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java index 593397330d..8f5d4ab9b5 100644 --- a/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java +++ b/src/main/java/net/minecraftforge/fml/packs/ResourcePackLoader.java @@ -31,6 +31,7 @@ import java.io.InputStream; import java.nio.file.Files; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; @@ -39,14 +40,18 @@ public class ResourcePackLoader private static Map modResourcePacks; private static ResourcePackList resourcePackList; - public static IResourcePack getResourcePackFor(String modId) + public static ModFileResourcePack getResourcePackFor(String modId) { return modResourcePacks.get(ModList.get().getModFileById(modId).getFile()); } @SuppressWarnings("unchecked") - public static T getResourcePackInfo(String modId) { - return (T)resourcePackList.getPackInfo(modId); + public static T getResourcePackInfoForModId(String modId) { + if (Objects.equals(modId, "minecraft")) { + // Additional resources for MC are associated with forge + return getResourcePackFor("forge").getPackInfo(); + } + return getResourcePackFor(modId).getPackInfo(); } public static void loadResourcePacks(ResourcePackList resourcePacks) { @@ -57,50 +62,6 @@ public class ResourcePackLoader resourcePacks.addPackFinder(new ModPackFinder()); } - private static class ForgeFolderPack extends FolderPack { - public ForgeFolderPack(final File folder) { - super(folder); - } - - public InputStream getResourceStream(ResourcePackType type, ResourceLocation location) throws IOException { - if (location.getPath().startsWith("lang/")) { - return super.getResourceStream(ResourcePackType.CLIENT_RESOURCES, location); - } else { - return super.getResourceStream(type, location); - } - } - - public boolean resourceExists(ResourcePackType type, ResourceLocation location) { - if (location.getPath().startsWith("lang/")) { - return super.resourceExists(ResourcePackType.CLIENT_RESOURCES, location); - } else { - return super.resourceExists(type, location); - } - } - } - - private static class ForgeFilePack extends FilePack { - public ForgeFilePack(final File folder) { - super(folder); - } - - public InputStream getResourceStream(ResourcePackType type, ResourceLocation location) throws IOException { - if (location.getPath().startsWith("lang/")) { - return super.getResourceStream(ResourcePackType.CLIENT_RESOURCES, location); - } else { - return super.getResourceStream(type, location); - } - } - - public boolean resourceExists(ResourcePackType type, ResourceLocation location) { - if (location.getPath().startsWith("lang/")) { - return super.resourceExists(ResourcePackType.CLIENT_RESOURCES, location); - } else { - return super.resourceExists(type, location); - } - } - - } private static class ModPackFinder implements IPackFinder { @Override @@ -109,7 +70,9 @@ public class ResourcePackLoader for (Entry e : modResourcePacks.entrySet()) { String name = "modfile/" + e.getKey().getFileName(); - packList.put(name, ResourcePackInfo.func_195793_a(name, true, ()->e.getValue(), factory, ResourcePackInfo.Priority.BOTTOM)); + final T packInfo = ResourcePackInfo.func_195793_a(name, true, () -> e.getValue(), factory, ResourcePackInfo.Priority.BOTTOM); + e.getValue().setPackInfo(packInfo); + packList.put(name, packInfo); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 2ae7447dbb..cb65a6db2d 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,11 +1,17 @@ modLoader="javafml" -loaderVersion="[2.0,]" +loaderVersion="[24,]" updateJSONURL="https://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json" issueTrackerURL="http://www.minecraftforge.net/" +logoFile="forge_logo.png" [[mods]] modId="forge" - version="${jarVersion}" + # We use the global forge version + version="${global.forgeVersion}" displayName="Forge" - description="Mod loading a compatibility API" + credits="LexManos,cpw,Mezz,fry,tterrag,gigaherz,illy" + authors="LexManos,cpw,Mezz,fry,Spacetoad,Eloraam" + description=''' + Forge, a broad compatibility API. + ''' \ No newline at end of file