Compare commits
3 Commits
04f1714ec5
...
e0b48e1c53
Author | SHA1 | Date |
---|---|---|
chylex | e0b48e1c53 | |
chylex | d070b4b22f | |
chylex | 2c12af5fa8 |
|
@ -1,5 +1,5 @@
|
||||||
<h2>Installation</h2>
|
<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>
|
<p>(*) Fabric API is <strong>not</strong> required.</p>
|
||||||
<h2>Configuration</h2>
|
<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>
|
<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;
|
package chylex.customwindowtitle.fabric;
|
||||||
import chylex.customwindowtitle.TitleConfig;
|
import chylex.customwindowtitle.TitleConfig;
|
||||||
import chylex.customwindowtitle.TitleParser;
|
import chylex.customwindowtitle.TitleParser;
|
||||||
|
import chylex.customwindowtitle.data.CommonTokenData;
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
@ -15,7 +16,7 @@ public class CustomWindowTitle implements ClientModInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
TokenData.register();
|
CommonTokenData.register(new TokenProvider());
|
||||||
Minecraft.getInstance().execute(this::updateTitle);
|
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,
|
"schemaVersion": 1,
|
||||||
"id": "customwindowtitle",
|
"id": "customwindowtitle",
|
||||||
|
"name": "${name}",
|
||||||
|
"description": "${description}",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
|
"license": "${license}",
|
||||||
|
|
||||||
"name": "Custom Window Title",
|
|
||||||
"authors": [
|
"authors": [
|
||||||
"chylex"
|
"${author}"
|
||||||
],
|
],
|
||||||
|
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://chylex.com",
|
"homepage": "https://chylex.com",
|
||||||
"sources": "https://github.com/chylex/Minecraft-Window-Title",
|
"issues": "${issuesURL}",
|
||||||
"issues": "https://github.com/chylex/Minecraft-Window-Title/issues"
|
"sources": "${sourcesURL}"
|
||||||
},
|
},
|
||||||
|
|
||||||
"license": "Unlicense",
|
|
||||||
|
|
||||||
"environment": "client",
|
"environment": "client",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"client": [
|
"client": [
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package chylex.customwindowtitle.forge;
|
package chylex.customwindowtitle.forge;
|
||||||
import chylex.customwindowtitle.TitleConfig;
|
import chylex.customwindowtitle.TitleConfig;
|
||||||
import chylex.customwindowtitle.TitleParser;
|
import chylex.customwindowtitle.TitleParser;
|
||||||
|
import chylex.customwindowtitle.data.CommonTokenData;
|
||||||
import com.mojang.blaze3d.platform.Window;
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -20,7 +21,7 @@ public class CustomWindowTitle {
|
||||||
config = TitleConfig.read(FMLPaths.CONFIGDIR.get().toString());
|
config = TitleConfig.read(FMLPaths.CONFIGDIR.get().toString());
|
||||||
ModLoadingContext.get().registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
ModLoadingContext.get().registerExtensionPoint(DisplayTest.class, () -> new DisplayTest(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup);
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup);
|
||||||
TokenData.register();
|
CommonTokenData.register(new TokenProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -1,24 +1,13 @@
|
||||||
package chylex.customwindowtitle.forge;
|
package chylex.customwindowtitle.forge;
|
||||||
import chylex.customwindowtitle.TokenException;
|
import chylex.customwindowtitle.TokenException;
|
||||||
import net.minecraft.SharedConstants;
|
import chylex.customwindowtitle.data.CommonTokenProvider;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
import net.minecraftforge.forgespi.language.IModFileInfo;
|
import net.minecraftforge.forgespi.language.IModFileInfo;
|
||||||
import net.minecraftforge.forgespi.language.IModInfo;
|
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 {
|
final class TokenProvider implements CommonTokenProvider {
|
||||||
static void register() {
|
@Override
|
||||||
registerToken("mcversion", noArgs(TokenData::getMinecraftVersion));
|
public String getModVersion(final String modId) {
|
||||||
registerToken("modversion", oneArg(TokenData::getModVersion));
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getMinecraftVersion() {
|
|
||||||
return SharedConstants.getCurrentVersion().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
static String getModVersion(final String modId) {
|
|
||||||
final IModFileInfo file = ModList.get().getModFileById(modId);
|
final IModFileInfo file = ModList.get().getModFileById(modId);
|
||||||
|
|
||||||
if (file == null) {
|
if (file == null) {
|
|
@ -1,15 +1,16 @@
|
||||||
modLoader = "javafml"
|
modLoader = "javafml"
|
||||||
loaderVersion = "[31,)"
|
loaderVersion = "[31,)"
|
||||||
|
|
||||||
authors = "chylex"
|
authors = "${author}"
|
||||||
license = "Unlicense"
|
license = "${license}"
|
||||||
issueTrackerURL = "https://github.com/chylex/Minecraft-Window-Title/issues"
|
issueTrackerURL = "${issuesURL}"
|
||||||
|
|
||||||
[[mods]]
|
[[mods]]
|
||||||
modId = "customwindowtitle"
|
modId = "customwindowtitle"
|
||||||
version = "1.1.0"
|
version = "${version}"
|
||||||
displayName = "Custom Window Title"
|
displayName = "${name}"
|
||||||
displayURL = "https://github.com/chylex/Minecraft-Window-Title"
|
description = "${description}"
|
||||||
|
displayURL = "${sourcesURL}"
|
||||||
|
|
||||||
[[dependencies.customwindowtitle]]
|
[[dependencies.customwindowtitle]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# Mod
|
# Mod
|
||||||
modId=customwindowtitle
|
modId=customwindowtitle
|
||||||
modName=Custom Window Title
|
modName=Custom Window Title
|
||||||
modDescription=
|
modDescription=Customize window title and icon.
|
||||||
modAuthor=chylex
|
modAuthor=chylex
|
||||||
modVersion=1.1.0
|
modVersion=1.1.1
|
||||||
modLicense=Unlicense
|
modLicense=Unlicense
|
||||||
modSourcesURL=https://github.com/chylex/Minecraft-Window-Title
|
modSourcesURL=https://github.com/chylex/Minecraft-Window-Title
|
||||||
modIssuesURL=https://github.com/chylex/Minecraft-Window-Title/issues
|
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