mirror of
https://github.com/TheWhiteDog9487/ServerAddressSpaceFix.git
synced 2024-11-10 09:07:04 +08:00
Fix refresh issue
- Fix the refresh issue by replacing @Inject with @Replace. This immediately trims the value of .getText() - Remove unused entrypoints and mixins
This commit is contained in:
parent
c863df68b8
commit
dbb2019bf3
@ -1,22 +1,14 @@
|
|||||||
package xyz.thewhitedog9487.mixin.client;
|
package xyz.thewhitedog9487.mixin.client;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
import net.minecraft.text.Text;
|
|
||||||
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;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(net.minecraft.client.gui.screen.AddServerScreen.class)
|
@Mixin(net.minecraft.client.gui.screen.AddServerScreen.class)
|
||||||
public class MixinAddServerScreen extends Screen {
|
public class MixinAddServerScreen {
|
||||||
protected MixinAddServerScreen(Text title) {
|
@Redirect(method = "addAndClose", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;getText()Ljava/lang/String;", ordinal = 1))
|
||||||
super(title);}
|
private String trimGetText(TextFieldWidget instance) {
|
||||||
|
return instance.getText().trim();
|
||||||
@Inject(method = "addAndClose()V", at = @At("RETURN"))
|
}
|
||||||
private void addAndClose(CallbackInfo ci){
|
|
||||||
var Server = ((AddServerScreenAccessor) this).Mixin_GetServer();
|
|
||||||
var Address = ((AddServerScreenAccessor) this).Mixin_GetAddressField().getText();
|
|
||||||
// this.server.address = this.addressField.getText();
|
|
||||||
Server.address = Address.trim();}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,16 @@
|
|||||||
package xyz.thewhitedog9487.mixin.client;
|
package xyz.thewhitedog9487.mixin.client;
|
||||||
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
import net.minecraft.text.Text;
|
|
||||||
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;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(net.minecraft.client.gui.screen.DirectConnectScreen.class)
|
@Mixin(net.minecraft.client.gui.screen.DirectConnectScreen.class)
|
||||||
public class MixinDirectConnectScreen extends Screen {
|
public class MixinDirectConnectScreen {
|
||||||
protected MixinDirectConnectScreen(Text title) {
|
@Redirect(method = "saveAndClose", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;getText()Ljava/lang/String;"))
|
||||||
super(title);}
|
private String trimGetText(TextFieldWidget instance) {
|
||||||
|
String trimmedText = instance.getText().trim();
|
||||||
@Inject(method = "saveAndClose()V", at = @At("RETURN"))
|
((DirectConnectScreenAccessor) this).Mixin_GetAddressField().setText(trimmedText);
|
||||||
private void addAndClose(CallbackInfo ci){
|
return trimmedText;
|
||||||
var ServerEntry = ((DirectConnectScreenAccessor) this).Mixin_GetServerEntry();
|
}
|
||||||
var Address = ((DirectConnectScreenAccessor) this).Mixin_GetAddressField().getText();
|
|
||||||
// this.serverEntry.address = this.addressField.getText();
|
|
||||||
ServerEntry.address = Address.trim();}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
"package": "xyz.thewhitedog9487.mixin.client",
|
"package": "xyz.thewhitedog9487.mixin.client",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"client": [
|
"client": [
|
||||||
"AddServerScreenAccessor",
|
"DirectConnectScreenAccessor",
|
||||||
"ExampleClientMixin",
|
|
||||||
"MixinAddServerScreen",
|
"MixinAddServerScreen",
|
||||||
"MixinDirectConnectScreen"
|
"MixinDirectConnectScreen"
|
||||||
],
|
],
|
||||||
|
@ -16,9 +16,6 @@
|
|||||||
"icon": "assets/twd-sasf/icon.png",
|
"icon": "assets/twd-sasf/icon.png",
|
||||||
"environment": "client",
|
"environment": "client",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
|
||||||
"xyz.thewhitedog9487.ServerAddressSpaceFix"
|
|
||||||
],
|
|
||||||
"client": [
|
"client": [
|
||||||
"xyz.thewhitedog9487.ServerAddressSpaceFixClient"
|
"xyz.thewhitedog9487.ServerAddressSpaceFixClient"
|
||||||
]
|
]
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"package": "xyz.thewhitedog9487.mixin",
|
"package": "xyz.thewhitedog9487.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [],
|
||||||
"ExampleMixin"
|
|
||||||
],
|
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user