File tree Expand file tree Collapse file tree
src/main/java/org/polyfrost/polyplus/mixin/client/cosmetics Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616@ Mixin (AbstractClientPlayer .class )
1717public abstract class AbstractClientPlayerMixin implements PlayerEmotesAccess , PlayerCosmeticsAccess {
1818 @ Unique
19- private final EmoteController polyplus$emoteController = new EmoteController () ;
19+ private EmoteController polyplus$emoteController ;
2020
2121 @ Unique
22- private final CosmeticEquipment polyplus$cosmeticEquipment = new CosmeticEquipment () ;
22+ private CosmeticEquipment polyplus$cosmeticEquipment ;
2323
2424 @ Override
2525 public EmoteController polyplus$emoteController () {
26- return polyplus$emoteController ;
26+ EmoteController controller = polyplus$emoteController ;
27+ if (controller == null ) {
28+ controller = new EmoteController ();
29+ polyplus$emoteController = controller ;
30+ }
31+ return controller ;
2732 }
2833
2934 @ Override
3035 public CosmeticEquipment polyplus$cosmeticEquipment () {
31- return polyplus$cosmeticEquipment ;
36+ CosmeticEquipment equipment = polyplus$cosmeticEquipment ;
37+ if (equipment == null ) {
38+ equipment = new CosmeticEquipment ();
39+ polyplus$cosmeticEquipment = equipment ;
40+ }
41+ return equipment ;
3242 }
3343
3444 @ Inject (method = "tick" , at = @ At ("RETURN" ))
3545 private void polyplus$tickEmote (CallbackInfo ci ) {
36- polyplus$emoteController .tick ((AbstractClientPlayer ) (Object ) this );
46+ polyplus$emoteController () .tick ((AbstractClientPlayer ) (Object ) this );
3747 }
3848}
3949//?}
Original file line number Diff line number Diff line change 2323*/ //?}
2424public class AvatarRenderStateMixin implements AvatarEmoteRenderAccess {
2525 @ Unique
26- private EmoteController polyplus$boundEmoteController = new EmoteController () ;
26+ private EmoteController polyplus$boundEmoteController ;
2727
2828 @ Unique
29- private Map <String , BoneTransform > polyplus$lastEmoteSample = Collections . emptyMap () ;
29+ private Map <String , BoneTransform > polyplus$lastEmoteSample ;
3030
3131 @ Override
3232 public EmoteController polyplus$boundEmoteController () {
33- return polyplus$boundEmoteController ;
33+ EmoteController controller = polyplus$boundEmoteController ;
34+ if (controller == null ) {
35+ controller = new EmoteController ();
36+ polyplus$boundEmoteController = controller ;
37+ }
38+ return controller ;
3439 }
3540
3641 @ Override
@@ -40,12 +45,13 @@ public class AvatarRenderStateMixin implements AvatarEmoteRenderAccess {
4045
4146 @ Override
4247 public Map <String , BoneTransform > polyplus$lastEmoteSample () {
43- return polyplus$lastEmoteSample ;
48+ Map <String , BoneTransform > sample = polyplus$lastEmoteSample ;
49+ return sample == null ? Collections .emptyMap () : sample ;
4450 }
4551
4652 @ Override
4753 public void polyplus$setLastEmoteSample (Map <String , BoneTransform > sample ) {
48- polyplus$lastEmoteSample = sample ;
54+ polyplus$lastEmoteSample = sample == null ? Collections . emptyMap () : sample ;
4955 }
5056}
5157//?}
Original file line number Diff line number Diff line change @@ -44,9 +44,11 @@ public class AvatarRendererMixin {
4444
4545 EmoteController controller = entity instanceof PlayerEmotesAccess playerAccess
4646 ? playerAccess .polyplus$emoteController ()
47- : new EmoteController () ;
47+ : null ;
4848
49- renderAccess .polyplus$bindEmoteController (controller );
49+ if (controller != null ) {
50+ renderAccess .polyplus$bindEmoteController (controller );
51+ }
5052 }
5153}
5254//?}
You can’t perform that action at this time.
0 commit comments