99import net .minecraft .util .math .BlockPos ;
1010import org .spongepowered .asm .mixin .Mixin ;
1111import org .spongepowered .asm .mixin .Shadow ;
12+ import org .spongepowered .asm .mixin .Unique ;
1213import org .spongepowered .asm .mixin .injection .At ;
1314import org .spongepowered .asm .mixin .injection .Inject ;
14- import org .spongepowered .asm .mixin .injection .Redirect ;
1515import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
16+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
1617
1718@ Mixin (value = WBlockPosEdit .class , remap = false , priority = 1001 )
1819public class WBlockPosEditMixin extends WHorizontalList {
@@ -36,9 +37,9 @@ public class WBlockPosEditMixin extends WHorizontalList {
3637 private boolean clicking ;
3738 @ Inject (method = "addTextBox" , at = @ At ("HEAD" ), cancellable = true )
3839 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 ();
4243 this .textBoxX .actionOnUnfocused = () -> {
4344 try {
4445 this .lastValue = this .value ;
@@ -84,20 +85,25 @@ private void addTextBox(CallbackInfo ci) {
8485 catch (NumberFormatException ignore ) { }
8586 };
8687
87-
88-
8988 if (ConfigModifier .get ().positionProtection .get ()) {
9089 textBoxX .set ("***" );
91- textBoxZ . set ( "***" );
90+ updateRender ( textBoxX );
9291 textBoxY .set ("***" );
92+ updateRender (textBoxY );
93+ textBoxZ .set ("***" );
94+ updateRender (textBoxZ );
9395 }
9496 ci .cancel ();
9597 }
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 ) {
98104 boolean validate = true ;
99105 boolean good ;
100- if (c == '-' && text .isEmpty () || text .equals ("***" )) {
106+ if (( c == '-' && text .isEmpty () ) || text .equals ("***" )) {
101107 good = true ;
102108 validate = false ;
103109 } else {
@@ -111,7 +117,6 @@ private boolean filter(String text, char c) {
111117 good = false ;
112118 }
113119 }
114-
115120 return good ;
116121 }
117122 @ Shadow
0 commit comments