mirror of
https://github.com/chylex/Minecraft-Window-Title.git
synced 2024-11-25 23:42:45 +01:00
Compare commits
No commits in common. "cb81efe63b34c1608b243664ff9026da11fdab29" and "02d6f2a63d666b1c39a3f4147777775e021ee593" have entirely different histories.
cb81efe63b
...
02d6f2a63d
53
.gitignore
vendored
53
.gitignore
vendored
@ -1,30 +1,29 @@
|
|||||||
# gradle
|
|
||||||
|
|
||||||
.gradle/
|
|
||||||
build/
|
|
||||||
out/
|
|
||||||
classes/
|
|
||||||
|
|
||||||
# eclipse
|
|
||||||
|
|
||||||
*.launch
|
|
||||||
|
|
||||||
# idea
|
|
||||||
|
|
||||||
.idea/
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
|
|
||||||
# vscode
|
|
||||||
|
|
||||||
.settings/
|
|
||||||
.vscode/
|
|
||||||
bin/
|
bin/
|
||||||
|
[Bb]uild/
|
||||||
|
eclipse/
|
||||||
|
run/
|
||||||
|
out/
|
||||||
|
.gradle/
|
||||||
|
.idea/$CACHE_FILE$
|
||||||
|
.idea/codeStyles/
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/dictionaries
|
||||||
|
.idea/inspectionProfiles/
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/libraries/
|
||||||
|
.idea/misc.xml
|
||||||
|
.idea/modules/
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/runConfigurations/
|
||||||
|
.idea/shelf/
|
||||||
|
.idea/uiDesigner.xml
|
||||||
|
.idea/workspace.xml
|
||||||
|
.settings/
|
||||||
|
.updateclasses/
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
.DS_Store
|
||||||
# fabric
|
*.launch
|
||||||
|
*.ipr
|
||||||
run/
|
*.iws
|
||||||
logs/
|
Thumbs.db
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
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 chylex.customwindowtitle.data.CommonTokenData;
|
||||||
|
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;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@ -21,6 +21,11 @@ public class CustomWindowTitle implements ClientModInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateTitle() {
|
private void updateTitle() {
|
||||||
Minecraft.getInstance().getWindow().setTitle(TitleParser.parse(config.getTitle()));
|
final Window window = Minecraft.getInstance().getWindow();
|
||||||
|
window.setTitle(TitleParser.parse(config.getTitle()));
|
||||||
|
|
||||||
|
if (config.hasIcon()) {
|
||||||
|
window.setIcon(config.readIcon16(), config.readIcon32());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package chylex.customwindowtitle.fabric;
|
package chylex.customwindowtitle.fabric;
|
||||||
|
|
||||||
import chylex.customwindowtitle.TokenException;
|
import chylex.customwindowtitle.TokenException;
|
||||||
import chylex.customwindowtitle.data.CommonTokenProvider;
|
import chylex.customwindowtitle.data.CommonTokenProvider;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
@ -15,7 +15,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = "[6.0,6.2)")
|
classpath(group = "net.minecraftforge.gradle", name = "ForgeGradle", version = "5.1.+") { isChanging = true }
|
||||||
classpath(group = "org.spongepowered", name = "mixingradle", version = "0.7-SNAPSHOT")
|
classpath(group = "org.spongepowered", name = "mixingradle", version = "0.7-SNAPSHOT")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,8 +41,6 @@ dependencies {
|
|||||||
configure<UserDevExtension> {
|
configure<UserDevExtension> {
|
||||||
mappings("official", minecraftVersion)
|
mappings("official", minecraftVersion)
|
||||||
|
|
||||||
copyIdeResources.set(true)
|
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
create("client") {
|
create("client") {
|
||||||
taskName = "Client"
|
taskName = "Client"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
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 chylex.customwindowtitle.data.CommonTokenData;
|
||||||
|
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;
|
||||||
import net.minecraftforge.fml.IExtensionPoint.DisplayTest;
|
import net.minecraftforge.fml.IExtensionPoint.DisplayTest;
|
||||||
@ -29,6 +29,11 @@ public class CustomWindowTitle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateTitle() {
|
private void updateTitle() {
|
||||||
Minecraft.getInstance().getWindow().setTitle(TitleParser.parse(config.getTitle()));
|
final Window window = Minecraft.getInstance().getWindow();
|
||||||
|
window.setTitle(TitleParser.parse(config.getTitle()));
|
||||||
|
|
||||||
|
if (config.hasIcon()) {
|
||||||
|
window.setIcon(config.readIcon16(), config.readIcon32());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package chylex.customwindowtitle.forge;
|
package chylex.customwindowtitle.forge;
|
||||||
|
|
||||||
import chylex.customwindowtitle.TokenException;
|
import chylex.customwindowtitle.TokenException;
|
||||||
import chylex.customwindowtitle.data.CommonTokenProvider;
|
import chylex.customwindowtitle.data.CommonTokenProvider;
|
||||||
import net.minecraftforge.fml.ModList;
|
import net.minecraftforge.fml.ModList;
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
modLoader = "javafml"
|
modLoader = "javafml"
|
||||||
loaderVersion = "[0,)"
|
loaderVersion = "[0,)"
|
||||||
|
|
||||||
|
authors = "${author}"
|
||||||
license = "${license}"
|
license = "${license}"
|
||||||
issueTrackerURL = "${issuesURL}"
|
issueTrackerURL = "${issuesURL}"
|
||||||
|
|
||||||
[[mods]]
|
[[mods]]
|
||||||
modId = "${id}"
|
modId = "${id}"
|
||||||
displayName = "${name}"
|
|
||||||
displayURL = "${sourcesURL}"
|
|
||||||
description = "${description}"
|
|
||||||
authors = "${author}"
|
|
||||||
version = "${version}"
|
version = "${version}"
|
||||||
|
displayName = "${name}"
|
||||||
|
description = "${description}"
|
||||||
|
displayURL = "${sourcesURL}"
|
||||||
|
|
||||||
[[dependencies.${id}]]
|
[[dependencies.${id}]]
|
||||||
modId = "minecraft"
|
modId = "minecraft"
|
||||||
|
@ -31,8 +31,6 @@ If any of the tokens aren't working, search the game log for **CustomWindowTitle
|
|||||||
|
|
||||||
### Changing the Icon
|
### Changing the Icon
|
||||||
|
|
||||||
**This feature is currently not supported in Minecraft 1.20.**
|
|
||||||
|
|
||||||
You must create two PNG images with sizes 16x16 and 32x32 pixels. The images **must be saved with transparency** even if they don't use it, **otherwise the icons will appear corrupted**. In Krita for example, you must check _Store alpha channel (transparency)_ when saving the image.
|
You must create two PNG images with sizes 16x16 and 32x32 pixels. The images **must be saved with transparency** even if they don't use it, **otherwise the icons will appear corrupted**. In Krita for example, you must check _Store alpha channel (transparency)_ when saving the image.
|
||||||
|
|
||||||
The _icon16_ and _icon32_ configuration entries point to the PNG files relative to the **.minecraft/config** folder. For example, if you place the two icons in a folder named _customwindowtitle_ as follows:
|
The _icon16_ and _icon32_ configuration entries point to the PNG files relative to the **.minecraft/config** folder. For example, if you place the two icons in a folder named _customwindowtitle_ as follows:
|
||||||
|
@ -3,21 +3,21 @@ modId=customwindowtitle
|
|||||||
modName=Custom Window Title
|
modName=Custom Window Title
|
||||||
modDescription=Customize window title and icon.
|
modDescription=Customize window title and icon.
|
||||||
modAuthor=chylex
|
modAuthor=chylex
|
||||||
modVersion=1.2.0
|
modVersion=1.1.2
|
||||||
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
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
minecraftVersion=1.20
|
minecraftVersion=1.19.3
|
||||||
#forgeVersion=46.0.1
|
forgeVersion=44.1.0
|
||||||
fabricVersion=0.14.21
|
fabricVersion=0.14.12
|
||||||
loomVersion=1.2
|
loomVersion=0.12
|
||||||
mixinVersion=0.8.5
|
mixinVersion=0.8.5
|
||||||
|
|
||||||
# Constraints
|
# Constraints
|
||||||
minimumMinecraftVersion=1.20
|
minimumMinecraftVersion=1.19.3
|
||||||
minimumForgeVersion=46.0.0
|
minimumForgeVersion=44.0.0
|
||||||
minimumFabricVersion=0.12.3
|
minimumFabricVersion=0.12.3
|
||||||
|
|
||||||
# Gradle
|
# Gradle
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1,25 +1,28 @@
|
|||||||
package chylex.customwindowtitle;
|
package chylex.customwindowtitle;
|
||||||
|
import net.minecraft.server.packs.resources.IoSupplier;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class TitleConfig {
|
public final class TitleConfig {
|
||||||
private static final ImmutableMap<String, String> DEFAULTS = ImmutableMap.<String, String>builder()
|
private static final Map<String, String> DEFAULTS;
|
||||||
.put("title", "Minecraft {mcversion}")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
private static final ImmutableSet<String> IGNORED_KEYS = ImmutableSet.of(
|
static {
|
||||||
"icon16",
|
final Map<String, String> defaults = new LinkedHashMap<>();
|
||||||
"icon32"
|
|
||||||
);
|
defaults.put("title", "Minecraft {mcversion}");
|
||||||
|
defaults.put("icon16", "");
|
||||||
|
defaults.put("icon32", "");
|
||||||
|
|
||||||
|
DEFAULTS = Collections.unmodifiableMap(defaults);
|
||||||
|
}
|
||||||
|
|
||||||
public static TitleConfig read(final String folder) {
|
public static TitleConfig read(final String folder) {
|
||||||
final Path configFile = Paths.get(folder, "customwindowtitle-client.toml");
|
final Path configFile = Paths.get(folder, "customwindowtitle-client.toml");
|
||||||
@ -43,7 +46,7 @@ public final class TitleConfig {
|
|||||||
if (config.containsKey(key)) {
|
if (config.containsKey(key)) {
|
||||||
config.put(key, value);
|
config.put(key, value);
|
||||||
}
|
}
|
||||||
else if (!IGNORED_KEYS.contains(key)) {
|
else {
|
||||||
throw new RuntimeException("CustomWindowTitle configuration has an invalid key: " + key);
|
throw new RuntimeException("CustomWindowTitle configuration has an invalid key: " + key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -52,7 +55,25 @@ public final class TitleConfig {
|
|||||||
throw new RuntimeException("CustomWindowTitle configuration error", e);
|
throw new RuntimeException("CustomWindowTitle configuration error", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new TitleConfig(config.get("title"));
|
final String icon16 = config.get("icon16");
|
||||||
|
final String icon32 = config.get("icon32");
|
||||||
|
|
||||||
|
final Path pathIcon16 = icon16.isEmpty() ? null : Paths.get(folder, icon16);
|
||||||
|
final Path pathIcon32 = icon32.isEmpty() ? null : Paths.get(folder, icon32);
|
||||||
|
|
||||||
|
if ((pathIcon16 == null) != (pathIcon32 == null)) {
|
||||||
|
throw new RuntimeException("CustomWindowTitle configuration specifies only one icon, both 'icon16' and 'icon32' must be set.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathIcon16 != null && Files.notExists(pathIcon16)) {
|
||||||
|
throw new RuntimeException("CustomWindowTitle 16x16 icon not found: " + pathIcon16);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathIcon32 != null && Files.notExists(pathIcon32)) {
|
||||||
|
throw new RuntimeException("CustomWindowTitle 32x32 icon not found: " + pathIcon32);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TitleConfig(config.get("title"), pathIcon16, pathIcon32);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String parseTrimmedValue(String value) {
|
private static String parseTrimmedValue(String value) {
|
||||||
@ -75,12 +96,28 @@ public final class TitleConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final String title;
|
private final String title;
|
||||||
|
private final Path icon16;
|
||||||
|
private final Path icon32;
|
||||||
|
|
||||||
private TitleConfig(final String title) {
|
private TitleConfig(final String title, final Path icon16, final Path icon32) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
this.icon16 = icon16;
|
||||||
|
this.icon32 = icon32;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasIcon() {
|
||||||
|
return icon16 != null && icon32 != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IoSupplier<InputStream> readIcon16() {
|
||||||
|
return IoSupplier.create(icon16);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IoSupplier<InputStream> readIcon32() {
|
||||||
|
return IoSupplier.create(icon32);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package chylex.customwindowtitle;
|
package chylex.customwindowtitle;
|
||||||
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@ -12,7 +11,7 @@ public final class TitleParser {
|
|||||||
private static final Logger logger = LogManager.getLogger("CustomWindowTitle");
|
private static final Logger logger = LogManager.getLogger("CustomWindowTitle");
|
||||||
|
|
||||||
public static String parse(final String input) {
|
public static String parse(final String input) {
|
||||||
final StringBuilder buffer = new StringBuilder();
|
final StringBuffer buffer = new StringBuffer();
|
||||||
final Matcher matcher = tokenRegex.matcher(input);
|
final Matcher matcher = tokenRegex.matcher(input);
|
||||||
|
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package chylex.customwindowtitle;
|
package chylex.customwindowtitle;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package chylex.customwindowtitle.data;
|
package chylex.customwindowtitle.data;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.SharedConstants;
|
|
||||||
|
|
||||||
public interface CommonTokenProvider {
|
public interface CommonTokenProvider {
|
||||||
default String getMinecraftVersion() {
|
default String getMinecraftVersion() {
|
||||||
return SharedConstants.getCurrentVersion().getName();
|
return Minecraft.getInstance().getGame().getVersion().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getModVersion(final String modId);
|
String getModVersion(final String modId);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
package chylex.customwindowtitle.mixin;
|
package chylex.customwindowtitle.mixin;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
Loading…
Reference in New Issue
Block a user