9
9
import net .minecraft .util .math .BlockPos ;
10
10
import org .spongepowered .asm .mixin .Mixin ;
11
11
import org .spongepowered .asm .mixin .Shadow ;
12
+ import org .spongepowered .asm .mixin .Unique ;
12
13
import org .spongepowered .asm .mixin .injection .At ;
13
14
import org .spongepowered .asm .mixin .injection .Inject ;
14
- import org .spongepowered .asm .mixin .injection .Redirect ;
15
15
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
16
+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
16
17
17
18
@ Mixin (value = WBlockPosEdit .class , remap = false , priority = 1001 )
18
19
public class WBlockPosEditMixin extends WHorizontalList {
@@ -36,9 +37,9 @@ public class WBlockPosEditMixin extends WHorizontalList {
36
37
private boolean clicking ;
37
38
@ Inject (method = "addTextBox" , at = @ At ("HEAD" ), cancellable = true )
38
39
private void addTextBox (CallbackInfo ci ) {
39
- this .textBoxX = this .add (this .theme .textBox (Integer .toString (this .value .getX ()), this ::filter )).minWidth (75.0 ).widget ();
40
- this .textBoxY = this .add (this .theme .textBox (Integer .toString (this .value .getY ()), this ::filter )).minWidth (75.0 ).widget ();
41
- this .textBoxZ = this .add (this .theme .textBox (Integer .toString (this .value .getZ ()), this ::filter )).minWidth (75.0 ).widget ();
40
+ this .textBoxX = this .add (this .theme .textBox (Integer .toString (this .value .getX ()), this ::filterFixed )).minWidth (75.0 ).widget ();
41
+ this .textBoxY = this .add (this .theme .textBox (Integer .toString (this .value .getY ()), this ::filterFixed )).minWidth (75.0 ).widget ();
42
+ this .textBoxZ = this .add (this .theme .textBox (Integer .toString (this .value .getZ ()), this ::filterFixed )).minWidth (75.0 ).widget ();
42
43
this .textBoxX .actionOnUnfocused = () -> {
43
44
try {
44
45
this .lastValue = this .value ;
@@ -84,20 +85,25 @@ private void addTextBox(CallbackInfo ci) {
84
85
catch (NumberFormatException ignore ) { }
85
86
};
86
87
87
-
88
-
89
88
if (ConfigModifier .get ().positionProtection .get ()) {
90
89
textBoxX .set ("***" );
91
- textBoxZ . set ( "***" );
90
+ updateRender ( textBoxX );
92
91
textBoxY .set ("***" );
92
+ updateRender (textBoxY );
93
+ textBoxZ .set ("***" );
94
+ updateRender (textBoxZ );
93
95
}
94
96
ci .cancel ();
95
97
}
96
- @ Shadow
97
- private boolean filter (String text , char c ) {
98
+ private void updateRender (WTextBox textBox ) {
99
+ textBoxX .setFocused (true );
100
+ textBoxX .setFocused (false );
101
+ }
102
+ @ Unique
103
+ private boolean filterFixed (String text , char c ) {
98
104
boolean validate = true ;
99
105
boolean good ;
100
- if (c == '-' && text .isEmpty () || text .equals ("***" )) {
106
+ if (( c == '-' && text .isEmpty () ) || text .equals ("***" )) {
101
107
good = true ;
102
108
validate = false ;
103
109
} else {
@@ -111,7 +117,6 @@ private boolean filter(String text, char c) {
111
117
good = false ;
112
118
}
113
119
}
114
-
115
120
return good ;
116
121
}
117
122
@ Shadow
0 commit comments