4343import org .spongepowered .asm .mixin .injection .Slice ;
4444
4545import java .util .ArrayList ;
46- import java .util .Collections ;
4746import java .util .List ;
4847
49- @ Mixin (value = PlayerTabOverlay .class )
48+ @ Mixin (PlayerTabOverlay .class /* unmapped name is C_4052762 */ )
5049public abstract class PlayerTabOverlayMixin extends GuiElement {
5150
5251 @ Shadow
5352 @ Final
5453 private Minecraft minecraft ;
5554
56- //TODO: Player list entries are left adjacent in 1.8... we need to made them centered instead
55+ //TODO: i should audit the code and ensure it's all consistent and good. using shares so often is not a good sign lol
56+ // the bedwars module in axolotlclient may or may not conflict... im not sure...
57+
58+ @ ModifyVariable (method = "render" , at = @ At ("STORE" ), index = 9 )
59+ private int axolotlclient$captureLocalN (int original , @ Share ("localRefN" ) LocalIntRef localRefN ) {
60+ /* honestly this could be written better, but, because of the modifications below, */
61+ /* the value of n changes. we need it to be the original value later on, so we should */
62+ /* store it for that usage */
63+ localRefN .set (original );
64+ return original ;
65+ }
66+
67+ @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 2 ), index = 9 )
68+ private int axolotlclient$leftToRightEntryPopulation (int original , @ Local (index = 10 ) int l ) {
69+ /* this local represents the rows per column */
70+ /* in 1.7, the value used here is the number of columns however */
71+ if (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .rowBasedEntryOrder .get ()) {
72+ return l ;
73+ }
74+ return original ;
75+ }
76+
77+ @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 3 ), index = 9 )
78+ private int axolotlclient$leftToRightEntryPopulation2 (int original , @ Local (index = 10 ) int l ) {
79+ /* ditto */
80+ if (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .rowBasedEntryOrder .get ()) {
81+ return l ;
82+ }
83+ return original ;
84+ }
85+
86+ @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 4 ), index = 9 )
87+ private int axolotlclient$useRightLocal (int original , @ Share ("localRefN" ) LocalIntRef localRefN ) {
88+ /* bro istg. the above modifications kinda mess up the local n. silly mixins */
89+ if (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .rowBasedEntryOrder .get ()) {
90+ return localRefN .get ();
91+ }
92+ return original ;
93+ }
94+
95+ @ ModifyVariable (method = "render" , at = @ At ("STORE" ), index = 20 )
96+ private int axolotlclient$captureLocalV (int original , @ Share ("localRefV" ) LocalIntRef localRefV ) {
97+ /* not again... */
98+ localRefV .set (original );
99+ return original ;
100+ }
101+
102+ @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 0 ), index = 20 )
103+ private int axolotlclient$swapLocals (int original , @ Local (index = 21 ) int t ) {
104+ /* this local represents the column index */
105+ /* in 1.7, the local called here is the row index local */
106+ if (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .rowBasedEntryOrder .get ()) {
107+ return t ;
108+ }
109+ return original ;
110+ }
111+
112+ @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 1 ), index = 21 )
113+ private int axolotlclient$swapLocals2 (int original , @ Share ("localRefV" ) LocalIntRef localRefV ) {
114+ /* this local represents the row index */
115+ /* in 1.7, the local called here is the column index local */
116+ if (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .rowBasedEntryOrder .get ()) {
117+ return localRefV .get ();
118+ }
119+ return original ;
120+ }
57121
58122 @ ModifyVariable (method = "render" , at = @ At ("STORE" ))
59123 private List <PlayerInfo > axolotlclient$doNotSortList (List <PlayerInfo > original , @ Local ClientPlayNetworkHandler clientPlayNetworkHandler ) {
@@ -64,17 +128,8 @@ public abstract class PlayerTabOverlayMixin extends GuiElement {
64128 return original ;
65129 }
66130
67- @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 0 ), index = 5 )
68- private List <PlayerInfo > axolotlclient$useOldObjectivesPositionLogic (List <PlayerInfo > original ) {
69- if (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .oldObjectivesPosition .get ()) {
70- /* because we're porting the 1.7 logic over below, we can just skip this for loop completely */
71- return Collections .EMPTY_LIST ;
72- }
73- return original ;
74- }
75-
76131 @ ModifyVariable (method = "render" , at = @ At ("LOAD" ), index = 6 , ordinal = 1 )
77- private int axolotlclient$useOldObjectivesPositionLogic2 (int original , @ Local (index = 25 ) String string2 ) {
132+ private int axolotlclient$useOldObjectivesPositionLogic (int original , @ Local (index = 25 ) String string2 ) {
78133 if (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .oldObjectivesPosition .get ()) {
79134 /* taken from 1.7 */
80135 return minecraft .textRenderer .getWidth (string2 ) + 4 ;
@@ -83,7 +138,7 @@ public abstract class PlayerTabOverlayMixin extends GuiElement {
83138 }
84139
85140 @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 0 ), index = 27 )
86- private int axolotlclient$useOldObjectivesPositionLogic3 (int original , @ Local (index = 22 ) int w , @ Share ("localRefAc" ) LocalIntRef localRefAc ) {
141+ private int axolotlclient$useOldObjectivesPositionLogic2 (int original , @ Local (index = 22 ) int w , @ Share ("localRefAc" ) LocalIntRef localRefAc ) {
87142 /* storing the original value for later use */
88143 localRefAc .set (original );
89144 /* we need to solely use the player name/head position to determine the placement of the objective number like 1.7 */
@@ -97,7 +152,7 @@ public abstract class PlayerTabOverlayMixin extends GuiElement {
97152 }
98153
99154 @ ModifyVariable (method = "render" , at = @ At (value = "LOAD" , ordinal = 1 ), index = 12 )
100- private int axolotlclient$useOldObjectivesPositionLogic4 (int original , @ Local (index = 13 ) int p ) {
155+ private int axolotlclient$useOldObjectivesPositionLogic3 (int original , @ Local (index = 13 ) int p ) {
101156 /* rahh */
102157 return OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .oldObjectivesPosition .get () ? p - 17 : original ;
103158 }
@@ -125,6 +180,12 @@ public abstract class PlayerTabOverlayMixin extends GuiElement {
125180 return OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .tabDimensions .get () ? minecraft .getNetworkHandler ().maxPlayerCount : original .call (instance );
126181 }
127182
183+ @ WrapOperation (method = "render" , at = @ At (value = "INVOKE" , target = "Ljava/util/List;subList(II)Ljava/util/List;" ))
184+ private <E extends PlayerInfo > List <E > axolotlclient$dontModifyPlayerList (List <E > list , int fromIndex , int toIndex , Operation <List <E >> original ) {
185+ /* don't modify the list just like 1.7 */
186+ return OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .tabDimensions .get () ? list : original .call (list , fromIndex , toIndex );
187+ }
188+
128189 @ WrapOperation (method = "render" , at = @ At (value = "INVOKE" , target = "Ljava/lang/Math;min(II)I" , ordinal = 1 ))
129190 private int axolotlclient$staticSlotWidth (int a , int b , Operation <Integer > original ) {
130191 /* makes the slot width static just like 1.7 */
@@ -176,10 +237,9 @@ public abstract class PlayerTabOverlayMixin extends GuiElement {
176237 return par1 - (OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .tabDimensions .get () ? 1 : 0 );
177238 }
178239
179- //TODO: This can be a better injection
180- @ ModifyExpressionValue (method = "renderPing" , at = @ At (value = "CONSTANT" , args = "intValue=11" ))
181- private int axolotlclient$movePingElement (int original ) {
240+ @ ModifyArg (method = "renderPing" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/overlay/PlayerTabOverlay;drawTexture(IIIIII)V" ), index = 1 )
241+ private int axolotlclient$movePingElement (int par1 ) {
182242 /* move the ping element */
183- return OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .tabDimensions .get () ? 12 : original ;
243+ return par1 - ( OldAnimationsConfig .isEnabled () && OldAnimationsConfig .instance .tabDimensions .get () ? 1 : 0 ) ;
184244 }
185245}
0 commit comments