11package net .earthcomputer .clientcommands .mixin ;
22
3+ import com .mojang .authlib .GameProfile ;
34import com .mojang .brigadier .StringReader ;
45import net .earthcomputer .clientcommands .command .ClientCommandManager ;
56import net .earthcomputer .clientcommands .features .PlayerRandCracker ;
67import net .earthcomputer .clientcommands .interfaces .IKeyBinding ;
78import net .earthcomputer .clientcommands .script .ScriptManager ;
9+ import net .earthcomputer .multiconnect .api .MultiConnectAPI ;
10+ import net .earthcomputer .multiconnect .api .Protocols ;
811import net .minecraft .client .MinecraftClient ;
12+ import net .minecraft .client .network .AbstractClientPlayerEntity ;
913import net .minecraft .client .network .ClientPlayerEntity ;
14+ import net .minecraft .client .world .ClientWorld ;
15+ import net .minecraft .enchantment .Enchantments ;
16+ import net .minecraft .entity .ExperienceOrbEntity ;
1017import net .minecraft .entity .ItemEntity ;
1118import net .minecraft .entity .damage .DamageSource ;
19+ import net .minecraft .item .ItemStack ;
1220import org .spongepowered .asm .mixin .Mixin ;
1321import org .spongepowered .asm .mixin .Unique ;
1422import org .spongepowered .asm .mixin .injection .At ;
1725import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
1826
1927@ Mixin (ClientPlayerEntity .class )
20- public class MixinClientPlayerEntity {
28+ public class MixinClientPlayerEntity extends AbstractClientPlayerEntity {
2129
2230 @ Unique private boolean wasSprintPressed = false ;
2331
32+ public MixinClientPlayerEntity (ClientWorld world , GameProfile profile ) {
33+ super (world , profile );
34+ }
35+
2436 @ Inject (method = "sendChatMessage" , at = @ At ("HEAD" ), cancellable = true )
2537 private void onSendChatMessage (String message , CallbackInfo ci ) {
2638 if (message .startsWith ("/" )) {
@@ -38,6 +50,16 @@ private void onSendChatMessage(String message, CallbackInfo ci) {
3850 }
3951 }
4052
53+ @ Inject (method = "tick" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;tick()V" ))
54+ private void onTick (CallbackInfo ci ) {
55+ if (Enchantments .MENDING .getEquipment (this ).values ().stream ()
56+ .anyMatch (stack -> stack .isDamaged () || MultiConnectAPI .instance ().getProtocolVersion () <= Protocols .V1_15_2 )) {
57+ if (!world .getEntitiesByClass (ExperienceOrbEntity .class , getBoundingBox (), null ).isEmpty ()) {
58+ PlayerRandCracker .onMending ();
59+ }
60+ }
61+ }
62+
4163 @ Inject (method = "dropSelectedItem" , at = @ At ("HEAD" ))
4264 public void onDropSelectedItem (boolean dropAll , CallbackInfoReturnable <ItemEntity > ci ) {
4365 PlayerRandCracker .onDropItem ();
0 commit comments