mirror of
https://github.com/TheWhiteDog9487/ServerAddressSpaceFix.git
synced 2024-11-10 00:57:04 +08:00
0.1.4
时间:2024 01 15 主要内容: 1. 更新开发环境到1.20.4 2. 更新Fabric Loader和Fabric API的版本 3. 使用YetAnotherConfigLib和ModMenu为模组创建一个配置屏幕 4. 配置选项中增加是否启用模组功能的开关 5. 移除自使用Redirect注解之后不再被需要的接口和方法 6. 在客户端侧的初始化方法中,让日志记录器打印一段日志,方便调试和除错 7. 更新Mixin注入的类的路径(这东西居然更新了)
This commit is contained in:
parent
ee6a656041
commit
789ad58006
@ -16,6 +16,11 @@ repositories {
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
|
||||
maven {
|
||||
name 'Xander Maven'
|
||||
url 'https://maven.isxander.dev/releases'}
|
||||
maven { url "https://maven.terraformersmc.com/releases/" }
|
||||
}
|
||||
|
||||
loom {
|
||||
@ -43,6 +48,9 @@ dependencies {
|
||||
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
||||
|
||||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||
modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:3.3.1+1.20.4"
|
||||
// https://maven.isxander.dev/#/releases/dev/isxander/yacl/yet-another-config-lib-fabric
|
||||
modImplementation "com.terraformersmc:modmenu:9.0.0"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -4,17 +4,17 @@ org.gradle.parallel=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.20.2
|
||||
yarn_mappings=1.20.2+build.4
|
||||
loader_version=0.14.23
|
||||
minecraft_version=1.20.4
|
||||
yarn_mappings=1.20.4+build.3
|
||||
loader_version=0.15.3
|
||||
|
||||
# Mod Properties
|
||||
mod_version=0.1.3
|
||||
mod_version=0.1.4
|
||||
maven_group=xyz.thewhitedog9487
|
||||
archives_base_name=ServerAddressSpaceFix
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.90.0+1.20.2
|
||||
fabric_version=0.93.1+1.20.4
|
||||
|
||||
loom_libraries_base=https://bmclapi2.bangbang93.com/maven/
|
||||
loom_resources_base=https://bmclapi2.bangbang93.com/assets/
|
||||
|
26
src/client/java/xyz/thewhitedog9487/ModMenu.java
Normal file
26
src/client/java/xyz/thewhitedog9487/ModMenu.java
Normal file
@ -0,0 +1,26 @@
|
||||
package xyz.thewhitedog9487;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import dev.isxander.yacl3.api.ConfigCategory;
|
||||
import dev.isxander.yacl3.api.Option;
|
||||
import dev.isxander.yacl3.api.OptionDescription;
|
||||
import dev.isxander.yacl3.api.YetAnotherConfigLib;
|
||||
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ModMenu implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return parent -> YetAnotherConfigLib.createBuilder()
|
||||
.title(Text.translatable("title.thewhitedog9487.twd-sasf.config"))
|
||||
.category(ConfigCategory.createBuilder()
|
||||
.name(Text.translatable("config.thewhitedog9487.twd-sasf.category.general"))
|
||||
.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.translatable("option.thewhitedog9487.twd-sasf.ModEnabled"))
|
||||
.binding(true, () -> Settings.ModEnabled, newVal -> Settings.ModEnabled = newVal)
|
||||
.description(OptionDescription.of(Text.translatable("option.thewhitedog9487.twd-sasf.ModEnabled.description")))
|
||||
.controller(TickBoxControllerBuilder::create)
|
||||
.build())
|
||||
.build())
|
||||
.build().generateScreen(parent);}}
|
@ -1,10 +1,14 @@
|
||||
package xyz.thewhitedog9487;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ServerAddressSpaceFixClient implements ClientModInitializer {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("twd-sasf");
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
|
||||
LOGGER.info("ServerAddressSpaceFix正在初始化!");
|
||||
}
|
||||
}
|
5
src/client/java/xyz/thewhitedog9487/Settings.java
Normal file
5
src/client/java/xyz/thewhitedog9487/Settings.java
Normal file
@ -0,0 +1,5 @@
|
||||
package xyz.thewhitedog9487;
|
||||
|
||||
public class Settings {
|
||||
public static boolean ModEnabled = true;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package xyz.thewhitedog9487.mixin.client;
|
||||
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.AddServerScreen.class)
|
||||
public interface AddServerScreenAccessor {
|
||||
@Accessor("server")
|
||||
ServerInfo Mixin_GetServer();
|
||||
|
||||
@Accessor("addressField")
|
||||
TextFieldWidget Mixin_GetAddressField();
|
||||
}
|
@ -5,11 +5,8 @@ import net.minecraft.client.network.ServerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.DirectConnectScreen.class)
|
||||
@Mixin(net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen.class)
|
||||
public interface DirectConnectScreenAccessor {
|
||||
@Accessor("serverEntry")
|
||||
ServerInfo Mixin_GetServerEntry();
|
||||
|
||||
@Accessor("addressField")
|
||||
TextFieldWidget Mixin_GetAddressField();
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.thewhitedog9487.Settings;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.AddServerScreen.class)
|
||||
@Mixin(net.minecraft.client.gui.screen.multiplayer.AddServerScreen.class)
|
||||
public class MixinAddServerScreen {
|
||||
@Redirect(method = "addAndClose", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;getText()Ljava/lang/String;", ordinal = 1))
|
||||
private String trimGetText(TextFieldWidget instance) {
|
||||
if( !Settings.ModEnabled ) { return instance.getText(); }
|
||||
return instance.getText().replace(" ", "");}}
|
@ -4,11 +4,13 @@ import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import xyz.thewhitedog9487.Settings;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.DirectConnectScreen.class)
|
||||
@Mixin(net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen.class)
|
||||
public class MixinDirectConnectScreen {
|
||||
@Redirect(method = "saveAndClose", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;getText()Ljava/lang/String;"))
|
||||
private String trimGetText(TextFieldWidget instance) {
|
||||
if( !Settings.ModEnabled ) { return instance.getText(); }
|
||||
String trimmedText = instance.getText().replace(" ", "");
|
||||
((DirectConnectScreenAccessor) this).Mixin_GetAddressField().setText(trimmedText);
|
||||
return trimmedText;}}
|
||||
return trimmedText;}}
|
@ -5,6 +5,7 @@ import net.fabricmc.api.ModInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Deprecated
|
||||
public class ServerAddressSpaceFix implements ModInitializer {
|
||||
// This logger is used to write text to the console and the log file.
|
||||
// It is considered best practice to use your mod id as the logger's name.
|
||||
|
@ -1,6 +1,10 @@
|
||||
{
|
||||
"modmenu.nameTranslation.twd-sasf": "ServerAddressSpaceFix",
|
||||
"modmenu.descriptionTranslation.twd-sasf": "Fixed the \"unknown host\" bug caused by the server address containing spaces at the beginning and end of the server address when adding a server or connecting directly",
|
||||
"modmenu.descriptionTranslation.twd-sasf": "Fixed the \"unknown host\" bug caused by the server address containing spaces at the beginning and end of the server address when adding a server or connecting directly\nTip: If you need to use the configuration menu, install the YetAnotherConfigLib mod",
|
||||
"twd-sasf.bilibili": "Bilibili",
|
||||
"twd-sasf.blog": "Blog"
|
||||
"twd-sasf.blog": "Blog",
|
||||
"title.thewhitedog9487.twd-sasf.config": "ServerAddressSpaceFix",
|
||||
"config.thewhitedog9487.twd-sasf.category.general": "General",
|
||||
"option.thewhitedog9487.twd-sasf.ModEnabled": "Whether To Enable The Mod Feature",
|
||||
"option.thewhitedog9487.twd-sasf.ModEnabled.description": "There is no need to restart the game, and the modification will take effect immediately after it is saved"
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
{
|
||||
"modmenu.nameTranslation.twd-sasf": "服务器地址首尾空格修复",
|
||||
"modmenu.descriptionTranslation.twd-sasf": "修复添加服务器或直接连接时,服务器地址首尾包含空格导致的“未知的主机”Bug",
|
||||
"modmenu.descriptionTranslation.twd-sasf": "修复添加服务器或直接连接时,服务器地址首尾包含空格导致的“未知的主机”Bug\n提示:如果需要使用配置菜单,请安装YetAnotherConfigLib模组",
|
||||
"twd-sasf.bilibili": "哔哩哔哩主页",
|
||||
"twd-sasf.blog": "TheWhiteDog9487的博客"
|
||||
"twd-sasf.blog": "TheWhiteDog9487的博客",
|
||||
"title.thewhitedog9487.twd-sasf.config": "服务器地址首尾空格修复",
|
||||
"config.thewhitedog9487.twd-sasf.category.general": "通用",
|
||||
"option.thewhitedog9487.twd-sasf.ModEnabled": "是否启用模组功能",
|
||||
"option.thewhitedog9487.twd-sasf.ModEnabled.description": "无需重启游戏,修改并保存后立刻生效"
|
||||
}
|
@ -16,9 +16,8 @@
|
||||
"icon": "assets/twd-sasf/icon.png",
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": [
|
||||
"xyz.thewhitedog9487.ServerAddressSpaceFixClient"
|
||||
]
|
||||
"client": [ "xyz.thewhitedog9487.ServerAddressSpaceFixClient" ],
|
||||
"modmenu": [ "xyz.thewhitedog9487.ModMenu" ]
|
||||
},
|
||||
"mixins": [
|
||||
"twd-sasf.mixins.json",
|
||||
@ -28,7 +27,7 @@
|
||||
}
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.23",
|
||||
"fabricloader": ">=0.15.3",
|
||||
"minecraft": ["1.20","1.20.*"],
|
||||
"java": ">=17"
|
||||
},
|
||||
|
@ -1,3 +1,14 @@
|
||||
# 0.1.4
|
||||
时间:2024 01 15
|
||||
主要内容:
|
||||
1. 更新开发环境到1.20.4
|
||||
2. 更新Fabric Loader和Fabric API的版本
|
||||
3. 使用YetAnotherConfigLib和ModMenu为模组创建一个配置屏幕
|
||||
4. 配置选项中增加是否启用模组功能的开关
|
||||
5. 移除自使用Redirect注解之后不再被需要的接口和方法
|
||||
6. 在客户端侧的初始化方法中,让日志记录器打印一段日志,方便调试和除错
|
||||
7. 更新Mixin注入的类的路径(这东西居然更新了)
|
||||
|
||||
# 0.1.3
|
||||
时间:2023 10 28
|
||||
主要内容:这玩意好像不具备特定版本兼容性啊,那我直接改兼容性列表以大版本作为兼容性边界得了,1.20全版本通用一个分支和同一个输出。
|
||||
|
Loading…
Reference in New Issue
Block a user