Compare commits
3 Commits
04f1714ec5
...
e0b48e1c53
Author | SHA1 | Date |
---|---|---|
chylex | e0b48e1c53 | |
chylex | d070b4b22f | |
chylex | 2c12af5fa8 |
|
@ -1,5 +1,5 @@
|
|||
<h2>Installation</h2>
|
||||
<p>The mod supports <a href="https://files.minecraftforge.net/">Forge</a> and <a href="https://fabricmc.net/">Fabric</a> (*) mod loaders, <strong>the same mod file will work in both</strong>. Follow either mod loader's installation guide, then <a href="https://www.curseforge.com/minecraft/mc-mods/custom-window-title/files">download the mod file</a> for your Minecraft version, and install it into the <strong>.minecraft/mods</strong> folder.</p>
|
||||
<p>The mod supports <a href="https://files.minecraftforge.net/">Forge</a> and <a href="https://fabricmc.net/">Fabric</a> (*) mod loaders. Follow either mod loader's installation guide, then <a href="https://www.curseforge.com/minecraft/mc-mods/custom-window-title/files">download the mod file</a> for your Minecraft version and mod loader, and install it into the <strong>.minecraft/mods</strong> folder.</p>
|
||||
<p>(*) Fabric API is <strong>not</strong> required.</p>
|
||||
<h2>Configuration</h2>
|
||||
<p>Run the game once to create the configuration file. By default, the window title will be set to <strong>Minecraft <em><version></em></strong>. Unlike in vanilla 1.15.2 onwards, the title will not change when you enter a world/server.</p>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package chylex.customwindowtitle.fabric;
|
||||
import chylex.customwindowtitle.TitleConfig;
|
||||
import chylex.customwindowtitle.TitleParser;
|
||||
import chylex.customwindowtitle.data.CommonTokenData;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
@ -15,7 +16,7 @@ public class CustomWindowTitle implements ClientModInitializer {
|
|||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
TokenData.register();
|
||||
CommonTokenData.register(new TokenProvider());
|
||||
Minecraft.getInstance().execute(this::updateTitle);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package chylex.customwindowtitle.fabric;
|
||||
import chylex.customwindowtitle.TokenException;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
import static chylex.customwindowtitle.TitleTokens.noArgs;
|
||||
import static chylex.customwindowtitle.TitleTokens.oneArg;
|
||||
import static chylex.customwindowtitle.TitleTokens.registerToken;
|
||||
|
||||
final class TokenData {
|
||||
static void register() {
|
||||
registerToken("mcversion", noArgs(TokenData::getMinecraftVersion));
|
||||
registerToken("modversion", oneArg(TokenData::getModVersion));
|
||||
}
|
||||
|
||||
static String getMinecraftVersion() {
|
||||
return SharedConstants.getCurrentVersion().getName();
|
||||
}
|
||||
|
||||
static String getModVersion(final String modId) {
|
||||
return FabricLoader.getInstance().getModContainer(modId).orElseThrow(() -> new TokenException("mod info for '" + modId + "' not found")).getMetadata().getVersion().getFriendlyString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package chylex.customwindowtitle.fabric;
|
||||
import chylex.customwindowtitle.TokenException;
|
||||
import chylex.customwindowtitle.data.CommonTokenProvider;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
final class TokenProvider implements CommonTokenProvider {
|
||||
@Override
|
||||
public String getModVersion(final String modId) {
|
||||
return FabricLoader.getInstance()
|
||||
.getModContainer(modId)
|
||||
.orElseThrow(() -> new TokenException("mod info for '" + modId + "' not found"))
|
||||
.getMetadata()
|
||||
.getVersion()
|
||||
.getFriendlyString();
|
||||
}
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "customwindowtitle",
|
||||
"name": "${name}",
|
||||
"description": "${description}",
|
||||
"version": "${version}",
|
||||
"license": "${license}",
|
||||
|
||||
"name": "Custom Window Title",
|
||||
"authors": [
|
||||
"chylex"
|
||||
"${author}"
|
||||
],
|
||||
|
||||
"contact": {
|
||||
"homepage": "https://chylex.com",
|
||||
"sources": "https://github.com/chylex/Minecraft-Window-Title",
|
||||
"issues": "https://github.com/chylex/Minecraft-Window-Title/issues"
|
||||
"issues": "${issuesURL}",
|
||||
"sources": "${sourcesURL}"
|
||||
},
|
||||
|
||||
"license": "Unlicense",
|
||||
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package chylex.customwindowtitle.forge;
|
||||
import chylex.customwindowtitle.TitleConfig;
|
||||
import chylex.customwindowtitle.TitleParser;
|
||||
import chylex.customwindowtitle.data.CommonTokenData;
|
||||
import com.mojang.blaze3d.platform.Window;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
@ -20,7 +21,7 @@ public class CustomWindowTitle {
|
|||
config = TitleConfig.read(FMLPaths.CONFIGDIR.get().toString());
|
||||
ModLoadingContext.get().registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup);
|
||||
TokenData.register();
|
||||
CommonTokenData.register(new TokenProvider());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
package chylex.customwindowtitle.forge;
|
||||
import chylex.customwindowtitle.TokenException;
|
||||
import net.minecraft.SharedConstants;
|
||||
import chylex.customwindowtitle.data.CommonTokenProvider;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import static chylex.customwindowtitle.TitleTokens.noArgs;
|
||||
import static chylex.customwindowtitle.TitleTokens.oneArg;
|
||||
import static chylex.customwindowtitle.TitleTokens.registerToken;
|
||||
|
||||
final class TokenData {
|
||||
static void register() {
|
||||
registerToken("mcversion", noArgs(TokenData::getMinecraftVersion));
|
||||
registerToken("modversion", oneArg(TokenData::getModVersion));
|
||||
}
|
||||
|
||||
static String getMinecraftVersion() {
|
||||
return SharedConstants.getCurrentVersion().getName();
|
||||
}
|
||||
|
||||
static String getModVersion(final String modId) {
|
||||
final class TokenProvider implements CommonTokenProvider {
|
||||
@Override
|
||||
public String getModVersion(final String modId) {
|
||||
final IModFileInfo file = ModList.get().getModFileById(modId);
|
||||
|
||||
if (file == null) {
|
|
@ -1,15 +1,16 @@
|
|||
modLoader = "javafml"
|
||||
loaderVersion = "[31,)"
|
||||
|
||||
authors = "chylex"
|
||||
license = "Unlicense"
|
||||
issueTrackerURL = "https://github.com/chylex/Minecraft-Window-Title/issues"
|
||||
authors = "${author}"
|
||||
license = "${license}"
|
||||
issueTrackerURL = "${issuesURL}"
|
||||
|
||||
[[mods]]
|
||||
modId = "customwindowtitle"
|
||||
version = "1.1.0"
|
||||
displayName = "Custom Window Title"
|
||||
displayURL = "https://github.com/chylex/Minecraft-Window-Title"
|
||||
version = "${version}"
|
||||
displayName = "${name}"
|
||||
description = "${description}"
|
||||
displayURL = "${sourcesURL}"
|
||||
|
||||
[[dependencies.customwindowtitle]]
|
||||
modId = "minecraft"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Mod
|
||||
modId=customwindowtitle
|
||||
modName=Custom Window Title
|
||||
modDescription=
|
||||
modDescription=Customize window title and icon.
|
||||
modAuthor=chylex
|
||||
modVersion=1.1.0
|
||||
modVersion=1.1.1
|
||||
modLicense=Unlicense
|
||||
modSourcesURL=https://github.com/chylex/Minecraft-Window-Title
|
||||
modIssuesURL=https://github.com/chylex/Minecraft-Window-Title/issues
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package chylex.customwindowtitle.data;
|
||||
|
||||
import static chylex.customwindowtitle.TitleTokens.noArgs;
|
||||
import static chylex.customwindowtitle.TitleTokens.oneArg;
|
||||
import static chylex.customwindowtitle.TitleTokens.registerToken;
|
||||
|
||||
public final class CommonTokenData {
|
||||
public static void register(final CommonTokenProvider provider) {
|
||||
registerToken("mcversion", noArgs(provider::getMinecraftVersion));
|
||||
registerToken("modversion", oneArg(provider::getModVersion));
|
||||
}
|
||||
|
||||
private CommonTokenData() {}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package chylex.customwindowtitle.data;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public interface CommonTokenProvider {
|
||||
default String getMinecraftVersion() {
|
||||
return Minecraft.getInstance().getGame().getVersion().getName();
|
||||
}
|
||||
|
||||
String getModVersion(final String modId);
|
||||
}
|
Loading…
Reference in New Issue