mirror of
https://github.com/TheWhiteDog9487/ServerAddressSpaceFix.git
synced 2024-11-21 20:17:03 +08:00
commit
082c354873
@ -1,22 +1,14 @@
|
||||
package xyz.thewhitedog9487.mixin.client;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.AddServerScreen.class)
|
||||
public class MixinAddServerScreen extends Screen {
|
||||
protected MixinAddServerScreen(Text title) {
|
||||
super(title);}
|
||||
|
||||
@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();}
|
||||
|
||||
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) {
|
||||
return instance.getText().trim();
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,16 @@
|
||||
package xyz.thewhitedog9487.mixin.client;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.screen.DirectConnectScreen.class)
|
||||
public class MixinDirectConnectScreen extends Screen {
|
||||
protected MixinDirectConnectScreen(Text title) {
|
||||
super(title);}
|
||||
|
||||
@Inject(method = "saveAndClose()V", at = @At("RETURN"))
|
||||
private void addAndClose(CallbackInfo ci){
|
||||
var ServerEntry = ((DirectConnectScreenAccessor) this).Mixin_GetServerEntry();
|
||||
var Address = ((DirectConnectScreenAccessor) this).Mixin_GetAddressField().getText();
|
||||
// this.serverEntry.address = this.addressField.getText();
|
||||
ServerEntry.address = Address.trim();}
|
||||
|
||||
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) {
|
||||
String trimmedText = instance.getText().trim();
|
||||
((DirectConnectScreenAccessor) this).Mixin_GetAddressField().setText(trimmedText);
|
||||
return trimmedText;
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,7 @@
|
||||
"package": "xyz.thewhitedog9487.mixin.client",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"AddServerScreenAccessor",
|
||||
"ExampleClientMixin",
|
||||
"DirectConnectScreenAccessor",
|
||||
"MixinAddServerScreen",
|
||||
"MixinDirectConnectScreen"
|
||||
],
|
||||
|
@ -16,9 +16,6 @@
|
||||
"icon": "assets/twd-sasf/icon.png",
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"xyz.thewhitedog9487.ServerAddressSpaceFix"
|
||||
],
|
||||
"client": [
|
||||
"xyz.thewhitedog9487.ServerAddressSpaceFixClient"
|
||||
]
|
||||
|
@ -2,9 +2,7 @@
|
||||
"required": true,
|
||||
"package": "xyz.thewhitedog9487.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ExampleMixin"
|
||||
],
|
||||
"mixins": [],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user