package ganarchy.chewstuff.mixin; import ganarchy.chewstuff.ChewComponents; import net.minecraft.server.network.ServerPlayerEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; /** * The mixin for server player entities. */ @Mixin(ServerPlayerEntity.class) public class DesyncFix { /** * Checks and corrects for desyncs. */ @Inject( at = @At("HEAD"), method = "onStatusEffectUpgraded(Lnet/minecraft/entity/effect/StatusEffectInstance;ZLnet/minecraft/entity/Entity;)V" ) private void chewstuff_onDesync(CallbackInfo cbinfo) { var self = (ServerPlayerEntity) (Object) this; var maybeInfo = ChewComponents.CHEW.maybeGet(self); maybeInfo.ifPresent(info -> { info.sendUpdate = true; }); } }